Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for message-reaction updates #762

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,13 @@ func (bot *BotAPI) Send(c Chattable) (Message, error) {
return Message{}, err
}

switch c.(type) {
case *DeleteMessageConfig:
return Message{}, nil
default:
break
}

var message Message
err = json.Unmarshal(resp.Result, &message)

Expand Down
26 changes: 26 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ type Update struct {
//
// optional
EditedMessage *Message `json:"edited_message,omitempty"`
// MessageReaction message indicating a user react event to a chat
// administrated by the bot
//
// optional
MessageReaction *Message `json:"message_reaction,omitempty"`
// ChannelPost new version of a message that is known to the bot and was
// edited
//
Expand Down Expand Up @@ -365,6 +370,10 @@ type Message struct {
//
// optional
From *User `json:"from,omitempty"`
// User is the subject of an atypical Update type, such as message_reaction;
//
// optional
User *User `json:"user,omitempty"`
// SenderChat is the sender of the message, sent on behalf of a chat. The
// channel itself for channel messages. The supergroup itself for messages
// from anonymous group administrators. The linked channel for messages
Expand Down Expand Up @@ -634,6 +643,14 @@ type Message struct {
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// OldReaction is the previous list of reacts for this User and Message.
//
// optional
OldReaction []*ReactionType `json:"old_reaction,omitempty"`
// NewReaction is the updated list of reacts for this User and Message.
//
// optional
NewReaction []*ReactionType `json:"new_reaction,omitempty"`
}

// Time converts the message timestamp into a Time.
Expand Down Expand Up @@ -3328,3 +3345,12 @@ type PreCheckoutQuery struct {
// optional
OrderInfo *OrderInfo `json:"order_info,omitempty"`
}

type ReactionType struct {
// The type of reaction, can be on of 'emoji', 'custom_emoji', 'paid'
Type string `json:"type,omitempty"`
// If type is 'emoji', specifies its unicode
Emoji string `json:"emoji,omitempty"`
// If type is 'custom_emoji', specifies its unique ID
CustomEmojiID string `json:"custom_emoji_id,omitempty"`
}