pyTelegramBotAPI: set_message_reaction() – How do I make my Telegram bot react with a specific emoji to any message it recieves?

  Kiến thức lập trình

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.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT