Skip to content

Commit c3304ed

Browse files
author
Syfaro
committed
update Message struct for new fields, add IsSuperGroup to Chat struct
1 parent a835dc9 commit c3304ed

File tree

1 file changed

+33
-24
lines changed

1 file changed

+33
-24
lines changed

types.go

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,36 +71,45 @@ func (c *Chat) IsGroup() bool {
7171
return c.Type == "group"
7272
}
7373

74+
// IsSuperGroup returns true if the Chat is a supergroup conversation
75+
func (c *Chat) IsSuperGroup() bool {
76+
return c.Type == "supergroup"
77+
}
78+
7479
// IsChannel returns true if the Chat is a channel
7580
func (c *Chat) IsChannel() bool {
7681
return c.Type == "channel"
7782
}
7883

7984
// Message is returned by almost every request, and contains data about almost anything.
8085
type Message struct {
81-
MessageID int `json:"message_id"`
82-
From User `json:"from"`
83-
Date int `json:"date"`
84-
Chat Chat `json:"chat"`
85-
ForwardFrom User `json:"forward_from"`
86-
ForwardDate int `json:"forward_date"`
87-
ReplyToMessage *Message `json:"reply_to_message"`
88-
Text string `json:"text"`
89-
Audio Audio `json:"audio"`
90-
Document Document `json:"document"`
91-
Photo []PhotoSize `json:"photo"`
92-
Sticker Sticker `json:"sticker"`
93-
Video Video `json:"video"`
94-
Voice Voice `json:"voice"`
95-
Caption string `json:"caption"`
96-
Contact Contact `json:"contact"`
97-
Location Location `json:"location"`
98-
NewChatParticipant User `json:"new_chat_participant"`
99-
LeftChatParticipant User `json:"left_chat_participant"`
100-
NewChatTitle string `json:"new_chat_title"`
101-
NewChatPhoto []PhotoSize `json:"new_chat_photo"`
102-
DeleteChatPhoto bool `json:"delete_chat_photo"`
103-
GroupChatCreated bool `json:"group_chat_created"`
86+
MessageID int `json:"message_id"`
87+
From User `json:"from"`
88+
Date int `json:"date"`
89+
Chat Chat `json:"chat"`
90+
ForwardFrom User `json:"forward_from"`
91+
ForwardDate int `json:"forward_date"`
92+
ReplyToMessage *Message `json:"reply_to_message"`
93+
Text string `json:"text"`
94+
Audio Audio `json:"audio"`
95+
Document Document `json:"document"`
96+
Photo []PhotoSize `json:"photo"`
97+
Sticker Sticker `json:"sticker"`
98+
Video Video `json:"video"`
99+
Voice Voice `json:"voice"`
100+
Caption string `json:"caption"`
101+
Contact Contact `json:"contact"`
102+
Location Location `json:"location"`
103+
NewChatParticipant User `json:"new_chat_participant"`
104+
LeftChatParticipant User `json:"left_chat_participant"`
105+
NewChatTitle string `json:"new_chat_title"`
106+
NewChatPhoto []PhotoSize `json:"new_chat_photo"`
107+
DeleteChatPhoto bool `json:"delete_chat_photo"`
108+
GroupChatCreated bool `json:"group_chat_created"`
109+
SuperGroupChatCreated bool `json:"supergroup_chat_created"`
110+
ChannelChatCreated bool `json:"channel_chat_created"`
111+
MigrateToChatID int `json:"migrate_to_chat_id"`
112+
MigrateFromChatID int `json:"migrate_from_chat_id"`
104113
}
105114

106115
// Time converts the message timestamp into a Time.
@@ -110,7 +119,7 @@ func (m *Message) Time() time.Time {
110119

111120
// IsGroup returns if the message was sent to a group.
112121
func (m *Message) IsGroup() bool {
113-
return m.From.ID != m.Chat.ID
122+
return m.Chat.IsGroup()
114123
}
115124

116125
// IsCommand returns true if message starts from /

0 commit comments

Comments
 (0)