skip to Main Content

When subscribing to certain channels, administrator approval is required. These channels use hidden links and do not have any usernames. After requesting to join, I am being asked questions by a bot to verify if I am a real user. I have been encountering this frequently lately. How can I achieve this using python-telegram-bot? Just explaining the logic would be sufficient. I am familiar with coding. Any hints would be helpful.

2

Answers


  1. If your bot has the required permissions in the chat in question, it will receive chat_join_request updates when a user requests to join. In PTB you can catch those with the ChatJoinRequestHandler. Your bot can then send (a single!) message to the user and if the user replies, it can also send more messages. Finally, your bot can approve or reject the request.


    Disclaimer: I’m currently the maintainer of python-telelegram-bot.

    Login or Signup to reply.
  2. As @callmestag explained above. Here is the piece of code(in pyTelegramBotApi library)

    @bot.chat_join_request_handler()
    def handle_join_request(message):
        user_id = message.from_user.id
        bot.send_message(user_id "message text")
        bot.approve_chat_join_request(message.chat.id, user_id)
        print(f"Request Approved for {user_id}")
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search