How to receive messages in group chats using telegram bot api

独自空忆成欢 提交于 2019-12-30 02:35:09

问题


My telegram bot receives messages sent by user to my bot in private chats but not receives messages sent by users in group chats. Any options/api for getting group chat messages also,.


回答1:


Talk to @botfather and disable the privacy mode.




回答2:


Sequence within a BotFather chat:

You: /setprivacy

BotFather: Choose a bot to change group messages settings.

You: @your_name_bot

BotFather: 'Enable' - your bot will only receive messages that either start with the '/' symbol or mention the bot by username.

'Disable' - your bot will receive all messages that people send to groups.

Current status is: ENABLED

You: Disable

BotFather: Success! The new status is: DISABLED. /help




回答3:


By default A Bot will receive only messages addressed to it by any user directly via posting by /command@YourBot any message you send. After that it vill be available via getUpdates API call. In browser it will be:

https://api.telegram.org/botToken/getupdates

Find the related message in output JSON and grab chatId. It will allow you to answer back with:

https://api.telegram.org/botToken/sendmessage?chat_id=123456788&text=My Answer


来源:https://stackoverflow.com/questions/38565952/how-to-receive-messages-in-group-chats-using-telegram-bot-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!