aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-02-05 17:10:08 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-02-05 17:10:08 +0300
commit00f6e41e71ff6c250e34988e870802b6ecc80baa (patch)
treef59235bf126cf7b219cd30507ee3f7f80af72aec
parent4b2969925bfee6c54afa1b8097177e8b931b8106 (diff)
Support venue messages
-rw-r--r--telegram/utils.go22
1 files changed, 17 insertions, 5 deletions
diff --git a/telegram/utils.go b/telegram/utils.go
index 6d668b3..ee7b4e8 100644
--- a/telegram/utils.go
+++ b/telegram/utils.go
@@ -364,6 +364,16 @@ func (c *Client) formatBantime(hours int64) int32 {
return until
}
+func (c *Client) formatLocation(location *client.Location) string {
+ return fmt.Sprintf(
+ "coordinates: %v,%v | https://www.google.com/maps/search/%v,%v/",
+ location.Latitude,
+ location.Longitude,
+ location.Latitude,
+ location.Longitude,
+ )
+}
+
func (c *Client) messageToText(message *client.Message) string {
if message.Content == nil {
log.Warnf("Unknown message (big emoji?): %#v", message)
@@ -399,12 +409,14 @@ func (c *Client) messageToText(message *client.Message) string {
return "chat title set to: " + changeTitle.Title
case client.TypeMessageLocation:
location, _ := message.Content.(*client.MessageLocation)
+ return c.formatLocation(location.Location)
+ case client.TypeMessageVenue:
+ venue, _ := message.Content.(*client.MessageVenue)
return fmt.Sprintf(
- "coordinates: %v,%v | https://www.google.com/maps/search/%v,%v/",
- location.Location.Latitude,
- location.Location.Longitude,
- location.Location.Latitude,
- location.Location.Longitude,
+ "*%s*\n%s\n%s",
+ venue.Venue.Title,
+ venue.Venue.Address,
+ c.formatLocation(venue.Venue.Location),
)
case client.TypeMessagePhoto:
photo, _ := message.Content.(*client.MessagePhoto)