From bd9a944ad4e66fd17ae153bd879154ab475d03cb Mon Sep 17 00:00:00 2001 From: Will Oliver Date: Thu, 19 Dec 2024 23:51:09 +0100 Subject: [PATCH 1/3] add support for message-reaction updates --- types.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/types.go b/types.go index 36c174b8..ecb4cb77 100644 --- a/types.go +++ b/types.go @@ -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 // @@ -634,6 +639,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. @@ -3328,3 +3341,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"` +} From ccfdc9d1e7510d32d2e095e2ad78bf828349b675 Mon Sep 17 00:00:00 2001 From: Will Oliver Date: Fri, 27 Dec 2024 22:29:06 +0100 Subject: [PATCH 2/3] add disappeared changes??? --- types.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/types.go b/types.go index ecb4cb77..e63a8c3d 100644 --- a/types.go +++ b/types.go @@ -370,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 @@ -642,11 +646,11 @@ type Message struct { // OldReaction is the previous list of reacts for this User and Message. // // optional - OldReaction *ReactionType `json:"old_reaction,omitempty"` + 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"` + NewReaction []*ReactionType `json:"new_reaction,omitempty"` } // Time converts the message timestamp into a Time. From 9cb4406c40c6a99a31300077b83f5e0e41b04daa Mon Sep 17 00:00:00 2001 From: Will Oliver Date: Thu, 2 Jan 2025 19:31:01 +0100 Subject: [PATCH 3/3] fix marshalling bug in bot.Send() when sending DeleteMessageConfig Chattable --- bot.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bot.go b/bot.go index 39037b8d..a6f8499d 100644 --- a/bot.go +++ b/bot.go @@ -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)