I’m working on a Telegram bot for a quiz game. I want players to take turns answering questions. The bot needs to tag each player when it’s their turn. It’s easy to mention users with usernames using @username
, but what about those without one?
In the Telegram app, you can mention users by @integer_id (name)
. This becomes a clickable link. I was hoping to do something similar in my bot.
I’m using the sendMessage
method with forceReply
to target specific users. This works great for those with usernames, but I’m stuck on how to handle users without them.
I can’t disable Privacy Mode as it would overload my server. Are there any other ways to make the bot listen to specific players?
I reached out to Telegram’s BotSupport. They said bots currently can’t mention users without usernames. For now, I’m sticking with forceReply
and asking users without usernames to set one up.
Has anyone found a workaround for this? Or any other ideas to target specific users in a group chat? Thanks for any help!
I’ve faced similar challenges with Telegram bots. One approach that worked for me was implementing a turn-based system using user IDs instead of usernames. When players join the game, store their user IDs and names in your database. Then, use these to track turns and send targeted messages.
For announcing turns, you could format messages like 'It’s [Player Name]‘s turn!’ This way, everyone knows who’s up next without needing to tag them directly. Combine this with forceReply, and you’ve got a decent workaround.
Another trick is to use inline keyboards with callback data containing the user’s ID. This allows you to create buttons specific to each player, making it easier to manage turns and responses.
It’s not perfect, but these methods have helped me run smoother game bots without relying on usernames or compromising privacy settings.
hey claire, i’ve been there too. privacy mode is a real pain sometimes. have u considered using custom keyboard buttons with each player’s name? it’s not perfect, but it could work as a visual cue for whose turn it is. might be worth a shot if u cant find another solution!
While there’s no direct way to tag users without usernames, you might consider a workaround using unique identifiers. When users join the game, assign them a number or code. Then, use that in your messages: “Player #42, it’s your turn!” This maintains privacy while still clearly indicating whose turn it is. Another option is to create a custom command for each player, like /player1_turn, which they can use to submit their answers. It’s not as smooth as tagging, but it could solve the targeting issue without relying on usernames.