11package telebot
22
3- // EmojiType defines emoji types.
4- type EmojiType = string
3+ import (
4+ "encoding/json"
5+ )
56
67// Reaction describes the type of reaction.
78// Describes an instance of ReactionTypeCustomEmoji and ReactionTypeEmoji.
@@ -10,7 +11,7 @@ type Reaction struct {
1011 Type string `json:"type"`
1112
1213 // Reaction emoji.
13- Emoji EmojiType `json:"emoji,omitempty"`
14+ Emoji string `json:"emoji,omitempty"`
1415
1516 // Custom emoji identifier.
1617 CustomEmoji string `json:"custom_emoji_id,omitempty"`
@@ -34,3 +35,33 @@ type ReactionOptions struct {
3435 // Pass True to set the reaction with a big animation.
3536 Big bool `json:"is_big"`
3637}
38+
39+ // React changes the chosen reactions on a message. Service messages can't be
40+ // reacted to. Automatically forwarded messages from a channel to its discussion group have
41+ // the same available reactions as messages in the channel.
42+ func (b * Bot ) React (to Recipient , msg Editable , opts ... ReactionOptions ) error {
43+ if to == nil {
44+ return ErrBadRecipient
45+ }
46+ msgID , _ := msg .MessageSig ()
47+
48+ params := map [string ]string {
49+ "chat_id" : to .Recipient (),
50+ "message_id" : msgID ,
51+ }
52+
53+ if len (opts ) > 0 {
54+ opt := opts [0 ]
55+
56+ if len (opt .Reactions ) > 0 {
57+ data , _ := json .Marshal (opt .Reactions )
58+ params ["reaction" ] = string (data )
59+ }
60+ if opt .Big {
61+ params ["is_big" ] = "true"
62+ }
63+ }
64+
65+ _ , err := b .Raw ("setMessageReaction" , params )
66+ return err
67+ }
0 commit comments