pyTelegramBotAPI 中带有参数的命令
Command with arguments in pyTelegramBotAPI
pyTelegramBotAPI 版本 - 3.0.1
python 的版本:
2.7/3.6.1
我想创建一个带参数的命令,例如:
/activate 1
/run programm
怎么做?
解决方案:
def extract_arg(arg):
return arg.split()[1:]
@bot.message_handler(commands=['yourCommand'])
def yourCommand(message):
status = extract_arg(message.text)
/yourCommand 1
status = ['1']
/yourCommand ff
status = ['ff']
pyTelegramBotAPI 版本 - 3.0.1
python 的版本: 2.7/3.6.1
我想创建一个带参数的命令,例如:
/activate 1
/run programm
怎么做?
解决方案:
def extract_arg(arg):
return arg.split()[1:]
@bot.message_handler(commands=['yourCommand'])
def yourCommand(message):
status = extract_arg(message.text)
/yourCommand 1
status = ['1']
/yourCommand ff
status = ['ff']