aboutsummaryrefslogtreecommitdiff
path: root/telegram/utils.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-02-05 19:33:53 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-02-05 19:33:53 +0300
commit7b90b8e4ae9c138f767641fbfa8ad700e8e27b55 (patch)
tree859314a71130eee4985b3b93634c48f8516af3c7 /telegram/utils.go
parentd2f35075e35f7ff0ca92a4fca7a8f07b3d139f90 (diff)
Support poll messages
Diffstat (limited to 'telegram/utils.go')
-rw-r--r--telegram/utils.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/telegram/utils.go b/telegram/utils.go
index 910bfd6..dbb65d7 100644
--- a/telegram/utils.go
+++ b/telegram/utils.go
@@ -489,6 +489,28 @@ func (c *Client) messageToText(message *client.Message) string {
case client.TypeMessageDice:
dice, _ := message.Content.(*client.MessageDice)
return fmt.Sprintf("%s 1d6: [%v]", dice.Emoji, dice.Value)
+ case client.TypeMessagePoll:
+ poll, _ := message.Content.(*client.MessagePoll)
+
+ rows := []string{}
+ rows = append(rows, fmt.Sprintf("*%s*", poll.Poll.Question))
+ for _, option := range poll.Poll.Options {
+ var tick string
+ if option.IsChosen {
+ tick = "x"
+ } else {
+ tick = " "
+ }
+ rows = append(rows, fmt.Sprintf(
+ "[%s] %s | %v%% | %v vote",
+ tick,
+ option.Text,
+ option.VotePercentage,
+ option.VoterCount,
+ ))
+ }
+
+ return strings.Join(rows, "\n")
}
return fmt.Sprintf("unknown message (%s)", message.Content.MessageContentType())