在 aiogram 中请求电话号码时出现问题。 Python
我的电报机器人中有一个“共享号码”按钮。该号码只能亲自发送给机器人,而不能通过群组发送。如果我尝试调用“/info”命令,控制台中会显示错误,因为该命令显示按钮,并且“共享号码”按钮与这些按钮一起显示。 “/info”命令仅适用于向机器人发送个人消息,并且此命令还发送“信息”消息。如何解决这个问题?如何使得调用“/info”命令时,组中显示“信息”,但不显示“分享号”按钮?
命令“/info”的处理程序:
asyns def command_botinfo(message: types.Message):
await message.reply("information ",reply_markup=kb_client)
另一个文件的一部分:
b5 = KeyboardButton("Share a number",request_contact=True)
kb_client = ReplyKeyboardMarkup(resize_keyboard=True,one_time_keyboard=True)
kb_client.add(b5)
I have a "Share number" button in my telegram bot. The number can be sent to the bot only in person, and not through a group. If I try to call the "/info" command, an error is displayed in the console, since this command shows buttons and the "Share number" button is shown along with these buttons. The "/info" command works only in a personal message to the bot, and this command also sends the "information" message. How to get around this problem? How to make it so that when the "/info" command is called, "information" is displayed in the group, but the "Share number" button is not displayed?
Handler for command "/info":
asyns def command_botinfo(message: types.Message):
await message.reply("information ",reply_markup=kb_client)
Part of another file:
b5 = KeyboardButton("Share a number",request_contact=True)
kb_client = ReplyKeyboardMarkup(resize_keyboard=True,one_time_keyboard=True)
kb_client.add(b5)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Aiogram 消息(类型:消息)具有聊天和类型属性,您可以简单地过滤私人或组
并且不要忘记在下一步中删除reply_markup
Aiogram message (types:Message) has chat and type attribute, you could simply filter private or group
And don't forget to remove reply_markup on the next step