[英]how to specify if the message was from group or private in python telegram bot
if chat.type == 'supergroup':
# Check if the bot's name was mentioned in the message
# if bot_name in message_text:
# Generate a response to the question
response_text = generate_response(message_text)
update.message.reply_text(response_text)
elif chat.type == 'private':
# Generate a response to the question
response_text = generate_response(message_text)
update.message.reply_text(response_text)
如果消息是在私人聊天中發送的,則私人工作正常,但如果它是從群組發送的,則機器人無法選擇消息。 該機器人也在該組中。
我嘗試 if chat.id < 0: if message.chat.type in ["group", "supergroup"]:
知道消息是否來自該組但沒有運氣。 只有私人在工作。
默認情況下,機器人看不到群聊中寫入的所有消息。 請查看官方 Telegram 文檔中的此常見問題解答條目以獲取更多信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.