Bob*_*Mod 1 python arguments telegram py-telegram-bot-api
pyTelegramBotAPI 版本 - 3.0.1
python版本:2.7/3.6.1
我想创建一个带参数的命令,例如:
/activate 1
/run programm
Run Code Online (Sandbox Code Playgroud)
怎么做?
解决方案:
def extract_arg(arg):
return arg.split()[1:]
@bot.message_handler(commands=['yourCommand'])
def yourCommand(message):
status = extract_arg(message.text)
Run Code Online (Sandbox Code Playgroud)
/你的命令 1
status = ['1']
Run Code Online (Sandbox Code Playgroud)
/你的命令ff
status = ['ff']
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3078 次 |
| 最近记录: |