Command with arguments in pyTelegramBotAPI

390
June 20, 2017, at 04:56 AM

pyTelegramBotAPI version - 3.0.1

Version of python: 2.7/3.6.1

I want to create a command with arguments, example:

/activate 1
/run programm

How to do it?

Answer 1

Solution:

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']
READ ALSO
Is there a way to create executable files in Python without os.chmod for *nix systems?

Is there a way to create executable files in Python without os.chmod for *nix systems?

By default open writes files with 666 octal permission: -rw-rw-rw-I wonder if there's a way to make open creates files with the execution bit set

338
NixOps - Configure Nginx proxy pass with Python Flask

NixOps - Configure Nginx proxy pass with Python Flask

I am new to Nix and trying to implement a service which passes Python Flask web services though Nginx proxy_passThis is what I have tried so far

432
Getters/Setters for Python Class

Getters/Setters for Python Class

So I am working on setting up a Python class that is to be used as a way to get/set parts of a dictionaryI'm trying to set it up so that I have a dictionary (for example ID Numbers : Names) and a variable that is the currently selected member of the dictionary

376
BPF for dynamic Python logging

BPF for dynamic Python logging

Fairly often I wish that logging in Python was a bit more dynamic, in order to understand what's going on either in production or in a test environment that's not my development machineThat's not only for performance analysis, but also to understand what's...

280