I’ve got a Telegram bot that downloads pictures and shows them in a slideshow right away. But here’s the thing: I only want people in my group to be able to send stuff to the bot. Is there a way to set this up? I’m worried about random folks sending pictures and messing up our presentation. Any ideas on how to make the bot only listen to our group members? I’m pretty new to this bot thing, so simple explanations would be great. Thanks!
One effective approach I’ve used is implementing a user authentication system. You can create a simple database or file that stores authorized user IDs. When a message comes in, your bot checks if the sender’s ID is in the approved list. If not, it simply ignores the message or sends a polite rejection.
For added security, consider adding a command that requires a password to register new users. This way, only you or trusted admins can add people to the authorized list. It’s a bit more work upfront, but it gives you fine-grained control over who can interact with your bot.
Remember to regularly review and update your authorized users list to keep it current.
I’ve been down this road before with my own Telegram bot, and I found a solid solution. You can implement a whitelist system using the chat_id of your group. Here’s how:
-
Get your group’s chat_id by adding your bot to the group and having it log incoming messages.
-
In your bot’s code, check the chat_id of incoming messages against your whitelist.
-
Only process messages from the approved chat_id.
This way, your bot will ignore messages from anyone outside your group. It’s pretty straightforward to set up and works like a charm. Just remember to update your whitelist if your group changes. Hope this helps!
hey there! i’ve dealt with this before. you can use the getChatMember method to check if a user is in your group. if they’re not, just ignore their messages. it’s pretty easy to set up and works great. lemme know if you need more help!