在电报 Bot 中,/ 不会按编码弹出 /caps
In telegram Bot, / doesn't pop up /caps as coded
我是电报机器人的新手。我有一个快速的问题,我遵循了电报机器人文档,这是我的代码:
from telegram.ext import Updater,CommandHandler,MessageHandler, Filters
import logging
updater = Updater(token='<Enter Token>')
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
dispatcher = updater.dispatcher
def start(bot, update):
bot.sendMessage(chat_id=update.message.chat_id, text="I'm a bot, please talk to me!")
def caps(bot, update, args):
text_caps = ' '.join(args).upper()
bot.sendMessage(chat_id=update.message.chat_id, text=text_caps)
start_handler = CommandHandler('start', start)
dispatcher.add_handler(start_handler)
caps_handler = CommandHandler('caps', caps, pass_args=True)
dispatcher.add_handler(caps_handler)
updater.start_polling()
现在当我去执行我的脚本时。
如果我输入 /caps hi,它会 returns HI 符合预期。
但我想当我输入 / 时,它会在弹出窗口中给我类似 /cap 的选项。但它没有
任何帮助将不胜感激。
我相信目前没有 API 来注册/-命令自动完成,你必须通过 /setcommands
.[=12= 手动列出你计划用 BotFather 实现的所有命令]
至少 documentation 是这样建议的。
我是电报机器人的新手。我有一个快速的问题,我遵循了电报机器人文档,这是我的代码:
from telegram.ext import Updater,CommandHandler,MessageHandler, Filters
import logging
updater = Updater(token='<Enter Token>')
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
dispatcher = updater.dispatcher
def start(bot, update):
bot.sendMessage(chat_id=update.message.chat_id, text="I'm a bot, please talk to me!")
def caps(bot, update, args):
text_caps = ' '.join(args).upper()
bot.sendMessage(chat_id=update.message.chat_id, text=text_caps)
start_handler = CommandHandler('start', start)
dispatcher.add_handler(start_handler)
caps_handler = CommandHandler('caps', caps, pass_args=True)
dispatcher.add_handler(caps_handler)
updater.start_polling()
现在当我去执行我的脚本时。
如果我输入 /caps hi,它会 returns HI 符合预期。
但我想当我输入 / 时,它会在弹出窗口中给我类似 /cap 的选项。但它没有
任何帮助将不胜感激。
我相信目前没有 API 来注册/-命令自动完成,你必须通过 /setcommands
.[=12= 手动列出你计划用 BotFather 实现的所有命令]
至少 documentation 是这样建议的。