How to limit Bot? Python Telegram bot



  • I have a question: How do I limit the bean? I mean, how do you make Telegram BOT work in my group?

    I mean, if CELLOWEC wants to write a BUT, BOT will ignore it, and it won't even react.

    Or if CELOVEC looks up and wants to add my BOT to his group, he won't make it.



  • I think you can check the group's identifier when you get a message from the bot, if it's your group, you can answer it, otherwise you can't react. You didn't tell me what library you're using, so I'll give you example using https://github.com/eternnoir/pyTelegramBotAPI :

    import telebot
    

    bot = telebot.TeleBot('ВАШ_ТОКЕН"')

    @bot.message_handler(commands=['start', 'help'])
    def send_welcome(message):
    cid = message.chat.id # Получаем ID группы (чата)
    if cid == 'ВАШ_ИДЕНТИФИКАТОР_ГРУППЫ':
    bot.reply_to(message, 'Привет, как ты?')

    bot.infinity_polling()
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2