From 00f6e41e71ff6c250e34988e870802b6ecc80baa Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Sat, 5 Feb 2022 09:10:08 -0500 Subject: [PATCH] Support venue messages --- telegram/utils.go | 22 +++++++++++++++++----- 1 file 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)