This is my code:
import telebot
BOT_TOKEN = '-'
bot = telebot.TeleBot(BOT_TOKEN)
@bot.message_handler(func=lambda message:True)
def thumbs_up(message):
bot.set_message_reaction(message.chat.id, message.id, '👍')
if __name__ == '__main__':
bot.polling()
And this is the error I get:
payload['reaction'] = json.dumps([r.to_dict() for r in reaction])
^^^^^^^^^
AttributeError: 'str' object has no attribute 'to_dict'
I don’t understand how I can use a JSON list like the docs say:
https://pytba.readthedocs.io/en/latest/sync_version/index.html#telebot.TeleBot.set_message_reaction
https://core.telegram.org/bots/api#setmessagereaction
It also says in the docs that the reaction parameter is optional but I get an error if I don’t include it.
2
Answers
The reaction should be a list, not a single emoji.
Use it like so:
0stone0 is absolutely right. But if you want to use constants instead of typing strings you can do it this way:
from telegram import ReactionTypeEmoji, constants
bot.set_message_reaction(message.chat.id, message.id, [ReactionTypeEmoji(constants.ReactionEmoji.ALIEN_MONSTER)], is_big=False)