Przemek D
Przemek D

Reputation: 1

Telegram Bot won't leave private chat

I created quite nice bot for telegram but facing now some issues with security. I want my bot to work only in certain group which i allow ( already done by group_id) but i want also to block option to write to my bot in private message. I could block adding to groups from BotFather options but still people can write to him in private messages.

I tried to use function when someone write to him:

bot.leave_chat(message.chat.id)

But bot still don't want to leave private conversation with people. How could I prevent in this or other way from adding my bot or trying to flood him with requests?

Upvotes: 0

Views: 2176

Answers (1)

Alex Medveshchek
Alex Medveshchek

Reputation: 685

Technically it's not possible to forbid people to write messages directly to a Bot:

  1. All bots, regardless of settings, will receive:
  • All service messages.
  • All messages from private chats with users.
  • All messages from channels where they are a member.

As per your question, I'd suggest to create a simple stub reply for private chats something like This Bot doesn't answer in private.

Leaving a chat might not "explain" people anything. I guess it rather will push them to try again and again, because it's not clear "Why bot disappears with no reason" ;)

Upvotes: 2

Related Questions