Support poll messages
This commit is contained in:
parent
d2f35075e3
commit
7b90b8e4ae
|
@ -489,6 +489,28 @@ func (c *Client) messageToText(message *client.Message) string {
|
||||||
case client.TypeMessageDice:
|
case client.TypeMessageDice:
|
||||||
dice, _ := message.Content.(*client.MessageDice)
|
dice, _ := message.Content.(*client.MessageDice)
|
||||||
return fmt.Sprintf("%s 1d6: [%v]", dice.Emoji, dice.Value)
|
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())
|
return fmt.Sprintf("unknown message (%s)", message.Content.MessageContentType())
|
||||||
|
|
Loading…
Reference in a new issue