我正在用python开发一个带有库python-telegram-bot
的小机器人,我遇到了一个小问题:
我有一个带有参数switch_inline_query_current_chat
的InlineKeyboardButton
,因此当用户单击它时,一个命令会自动写入其聊天记录中
但是,该命令前面提到了bot(带有@)
问题是在这种情况下,我的机器人没有应答,我也不知道为什么
有没有一个解决方案,使按钮不在命令前面提到机器人
从@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 telegram机器人专家,但问题/修复应该与库无关
您的^{
这将
/get
命令链接到getEntry
处理程序问题
由于该命令仅在
/get
触发,,因此需要添加第二个具有bot名称的命令,以便它也将注册该命令第一个参数(
command
)接受str
或list
作为docs shows在其他图书馆也有同样的问题,不要认为有“更干净”的方法来处理这个问题。
相关问题 更多 >
编程相关推荐