Merge pull request #269 from godande/develop

Dice API support
pull/271/head
demget 4 years ago committed by GitHub
commit 81f4447261
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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.Dice != nil:
b.handle(OnDice, m)
default:
return false
}

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

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

@ -353,3 +353,19 @@ func (p *Poll) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) {
return extractMessage(data)
}
// Send delivers dice through bot b to recipient
func (d *Dice) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) {
params := map[string]string{
"chat_id": to.Recipient(),
"emoji": string(d.Type),
}
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:
@ -200,3 +200,10 @@ const (
)
const DefaultApiURL = "https://api.telegram.org"
type DiceType string
var (
Cube = &Dice{Type: "🎲"}
Dart = &Dice{Type: "🎯"}
)

Loading…
Cancel
Save