Improve location text

This commit is contained in:
Tulir Asokan
2017-11-26 00:18:20 +02:00
parent adeb271c1b
commit ba3667db0e
+8 -1
View File
@@ -147,7 +147,14 @@ class TelegramUser {
})
}
sendLocation(roomID, { long = 0.0, lat = 0.0, body = "Location" } = {}) {
sendLocation(roomID, { long = 0.0, lat = 0.0, body } = {}) {
if (!body) {
const longChar = long > 0 ? "E" : "W"
const latChar = lat > 0 ? "N" : "S"
const roundedLong = Math.abs(Math.round(long * 100000) / 100000)
const roundedLat = Math.abs(Math.round(lat * 100000) / 100000)
body = `Location: ${roundedLat}° ${latChar}, ${roundedLong}° ${longChar}`
}
return this.intent.sendMessage(roomID, {
msgtype: "m.location",
geo_uri: `geo:${lat},${long}`,