I’m trying to create a chatbot that will read the number of reactions and send them to me. In the pyTelegramBotAPI documentation, I found the message_reaction_count_handler and message_reaction_handler methods, but both of them do not work. There is almost no information on the Internet since this is a recent update.
import telebot
from telebot.types import *
TOKEN = 'token'
bot = telebot.TeleBot(TOKEN)
@bot.message_handler(func=lambda message: True)
def message_handler(message):
bot.send_message(message.chat.id, message.text)
@bot.message_reaction_handler(func=lambda update: True)
async def message_reaction_handler(update: MessageReactionUpdated):
print("Reaction update received:")
print(f'Message ID: {update.message_id}')
for reaction in update.reactions:
print(f'Reaction: {reaction.type.type}, Count: {reaction.total_count}')
@bot.message_reaction_count_handler(func=lambda update: True)
async def message_reaction_count_handler(update: MessageReactionCountUpdated):
print("Reaction update received:")
print(f'Message ID: {update.message_id}')
for reaction in update.reactions:
print(f'Reaction: {reaction.type.type}, Count: {reaction.total_count}')
if __name__ == '__main__':
bot.polling(none_stop=True)
The message_handler function is working
New contributor
LeonardiK is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.