【发布时间】:2020-09-26 07:08:05
【问题描述】:
我正在使用库 python-telegram-bot 在 python 中开发一个小机器人,但遇到了一个小问题:
我有一个InlineKeyboardButton,参数为switch_inline_query_current_chat,所以当用户点击它时,会自动在其聊天中写入一条命令。
但是,该命令之前提到了机器人(带有@)。
问题是我的机器人在这种情况下没有回答,我不知道为什么..
有没有一种解决方案可以让按钮不在命令之前提到机器人?
来自@BotFather 的群组被允许并且隐私群组被关闭。
非常感谢
编辑:这是 CommandHandler 的代码:
def getEntry(update, context):
if not (is_allowed_user(update.message.from_user.username, 'getEntry')):
context.bot.send_message(chat_id=update.effective_chat.id,
text='Who the hell are you @' + update.message.from_user.username + ' ?')
return
search = ' '.join(context.args)
infos, err = get_infos_people(search)
if err is not None:
context.bot.send_message(chat_id=update.effective_chat.id, text=err)
return
context.bot.send_message(chat_id=update.effective_chat.id, text=beautify_infos(infos),
parse_mode=ParseMode.MARKDOWN, reply_markup=getMainKeyboard(infos))
get_handler = CommandHandler('get', getEntry, filters=~Filters.update.edited_message)
这是按钮的代码:
def getMainKeyboard(infos):
keyboard = [InlineKeyboardButton("modify",
switch_inline_query_current_chat="/get " + infos[0] + "<write here>")]]
return InlineKeyboardMarkup(keyboard)
【问题讨论】:
-
请分享您的代码,尤其是命令处理程序!
-
当然!我刚刚编辑了我的帖子以添加一些代码!
标签: python bots telegram telegram-bot python-telegram-bot