0

I wanna make a telegram bot game where bot send a message to group then other members can make reactions on this message. Then I enlist those members data and start the game for those members only.

How can I achive this functionality?

I tried

bot.on('message', async (msg) => {
 const updates = await bot.getUpdates()
 updates.forEach(async (update) => {
 console.log(update)
 })
})

But using this code I didn't avail to get reaction updates for messages.

1 Answer 1

0

At first, it is important to explicitly mention the "message_reaction" update type in the allowed_updates for the bot.

const bot = new TelegramBot(token, {
 polling: {
 params: {
 allowed_updates: ["message", "message_reaction"],
 }
 }
});

Now you can listen to changes in message reaction as follows:

bot.on("message_reaction", (reaction) => {
 // `reaction` is of type MessageReactionUpdated (https://core.telegram.org/bots/api#messagereactionupdated)
 // `reaction.user` will be the user who changed the reaction
 // `reaction.chat` will be the chat on which the message to which the reaction is updated exist
});

Make sure to check the official documentation for detailed info on different properties available and customize your bot.

answered Jun 1, 2024 at 6:20
Sign up to request clarification or add additional context in comments.

2 Comments

Do you know how to get the message content based on the reaction event?
I have tried exactly that but the callback is never called. Do you have an idea? Do I have to enable something else?

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.