update Message struct for new fields, add IsSuperGroup to Chat struct

bot-api-6.1
Syfaro 2015-12-09 20:08:37 -06:00
parent a835dc9a96
commit c3304ed8a7
1 changed files with 33 additions and 24 deletions

View File

@ -71,6 +71,11 @@ func (c *Chat) IsGroup() bool {
return c.Type == "group" return c.Type == "group"
} }
// IsSuperGroup returns true if the Chat is a supergroup conversation
func (c *Chat) IsSuperGroup() bool {
return c.Type == "supergroup"
}
// IsChannel returns true if the Chat is a channel // IsChannel returns true if the Chat is a channel
func (c *Chat) IsChannel() bool { func (c *Chat) IsChannel() bool {
return c.Type == "channel" return c.Type == "channel"
@ -78,29 +83,33 @@ func (c *Chat) IsChannel() bool {
// Message is returned by almost every request, and contains data about almost anything. // Message is returned by almost every request, and contains data about almost anything.
type Message struct { type Message struct {
MessageID int `json:"message_id"` MessageID int `json:"message_id"`
From User `json:"from"` From User `json:"from"`
Date int `json:"date"` Date int `json:"date"`
Chat Chat `json:"chat"` Chat Chat `json:"chat"`
ForwardFrom User `json:"forward_from"` ForwardFrom User `json:"forward_from"`
ForwardDate int `json:"forward_date"` ForwardDate int `json:"forward_date"`
ReplyToMessage *Message `json:"reply_to_message"` ReplyToMessage *Message `json:"reply_to_message"`
Text string `json:"text"` Text string `json:"text"`
Audio Audio `json:"audio"` Audio Audio `json:"audio"`
Document Document `json:"document"` Document Document `json:"document"`
Photo []PhotoSize `json:"photo"` Photo []PhotoSize `json:"photo"`
Sticker Sticker `json:"sticker"` Sticker Sticker `json:"sticker"`
Video Video `json:"video"` Video Video `json:"video"`
Voice Voice `json:"voice"` Voice Voice `json:"voice"`
Caption string `json:"caption"` Caption string `json:"caption"`
Contact Contact `json:"contact"` Contact Contact `json:"contact"`
Location Location `json:"location"` Location Location `json:"location"`
NewChatParticipant User `json:"new_chat_participant"` NewChatParticipant User `json:"new_chat_participant"`
LeftChatParticipant User `json:"left_chat_participant"` LeftChatParticipant User `json:"left_chat_participant"`
NewChatTitle string `json:"new_chat_title"` NewChatTitle string `json:"new_chat_title"`
NewChatPhoto []PhotoSize `json:"new_chat_photo"` NewChatPhoto []PhotoSize `json:"new_chat_photo"`
DeleteChatPhoto bool `json:"delete_chat_photo"` DeleteChatPhoto bool `json:"delete_chat_photo"`
GroupChatCreated bool `json:"group_chat_created"` GroupChatCreated bool `json:"group_chat_created"`
SuperGroupChatCreated bool `json:"supergroup_chat_created"`
ChannelChatCreated bool `json:"channel_chat_created"`
MigrateToChatID int `json:"migrate_to_chat_id"`
MigrateFromChatID int `json:"migrate_from_chat_id"`
} }
// Time converts the message timestamp into a Time. // Time converts the message timestamp into a Time.
@ -110,7 +119,7 @@ func (m *Message) Time() time.Time {
// IsGroup returns if the message was sent to a group. // IsGroup returns if the message was sent to a group.
func (m *Message) IsGroup() bool { func (m *Message) IsGroup() bool {
return m.From.ID != m.Chat.ID return m.Chat.IsGroup()
} }
// IsCommand returns true if message starts from / // IsCommand returns true if message starts from /