简体   繁体   中英

python-telegram-bot replying to specific user in group chat

I am working on a telegram bot project for local people in my area, I would like to know is it possible for bot to reply back to same user that send the command in group chat, but not have the rest of the group see it. I thought I saw this as a possibility, but I cannot find it on python-telegram-bot github.

I am not looking for a copy/pastable code, I just need help in the right direction, I haven't received any responses in the telegram group chat on the matter.

Any help is appreciated.

You have a few options

  1. Just reply in a private chat
    You can just send a message to the users id. The problem is, the user have to unlock you before, by sending your bot /start . This may be practical for small groups.
  2. Guide the user to a private chat
    You can send a link with the format t.me/your_bot?start=XXXX . The user starts your bot in a private chat and sends the parameter ( XXXX ). Then you can evalute if its the right keyword and user and then send your message. Even more elegant is to use a InlineKeyBoardButton with this url.
  3. Use a button with an alert
    You can reply with an InlineKeyBoardButton and use answerCallbackQuery with show_alert=True to show a text when the right user clicks it like @nnbbot does it. The drawback of this method is, you can only use up to 200 charachters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM