dice: fixed dice handling

pull/269/head
dande 4 years ago
parent ab0c9a7060
commit 3915e8596b

@ -487,6 +487,8 @@ func (b *Bot) handleMedia(m *Message) bool {
b.handle(OnLocation, m)
case m.Venue != nil:
b.handle(OnVenue, m)
case m.DiceResult != nil:
b.handle(OnDice, m)
default:
return false
}

@ -1,6 +0,0 @@
package telebot
type Dice struct {
EmojiType string `json:"emoji"`
Value int `json:"value"`
}

@ -210,3 +210,8 @@ type Venue struct {
FoursquareID string `json:"foursquare_id,omitempty"`
FoursquareType string `json:"foursquare_type,omitempty"`
}
type Dice struct {
EmojiType string `json:"emoji"`
Value int `json:"value"`
}

@ -192,7 +192,7 @@ type Message struct {
// Inline keyboard attached to the message.
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup"`
DiceResult Dice `json:"dice"`
DiceResult *Dice `json:"dice"`
}
// MessageEntity object represents "special" parts of text messages,

@ -353,15 +353,15 @@ func (p *Poll) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) {
return extractMessage(data)
}
func(d *Dice) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) {
func (d *Dice) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) {
params := map[string]string{
"chat_id": to.Recipient(),
"emoji": d.EmojiType,
"chat_id": to.Recipient(),
"emoji": d.EmojiType,
}
embedSendOptions(params,opt)
embedSendOptions(params, opt)
data, err := b.Raw("sendDice", params)
if err != nil {
return nil, err
}
return extractMessage(data)
}
}

@ -58,7 +58,7 @@ const (
OnPinned = "\apinned"
OnChannelPost = "\achan_post"
OnEditedChannelPost = "\achan_edited_post"
OnDice = "\adice"
// Will fire when bot is added to a group.
OnAddedToGroup = "\aadded_to_group"
// Group events:

Loading…
Cancel
Save