diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-02-05 19:33:53 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-02-05 19:33:53 +0300 |
commit | 7b90b8e4ae9c138f767641fbfa8ad700e8e27b55 (patch) | |
tree | 859314a71130eee4985b3b93634c48f8516af3c7 /telegram/utils.go | |
parent | d2f35075e35f7ff0ca92a4fca7a8f07b3d139f90 (diff) |
Support poll messages
Diffstat (limited to 'telegram/utils.go')
-rw-r--r-- | telegram/utils.go | 22 |
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()) |