Command handler for Pavlov
Project description
Pavlov Commando
To handle commands in a easy way
##Example
from pvlv_commando.pvlv_commando import Commando
from pvlv_commando import CommandExecutionFail, ManualExecutionFail
def handler():
com = Commando()
text = '.command la vita se bella -d ciao -f -g' # An example of incoming text from the chat
permissions = 10
if text.startswith('.'):
try:
# text without the command invocation word, and the language of the command
com.find_command(text[1:], 'eng', permissions)
"""
Send to the chat with parse mode enabled
** mean bold
- if your chat dont support parse mode use com.run_manual().replace('**', '')
- if your chat have a different parse mode use com.run_manual().replace('**', 'your_format')
"""
man = com.run_manual()
print(man) if man else None
com.run_command(None) # here you have to pass the bot object that will be used
# Do exception handling as you please
except CommandExecutionFail as exc:
print(exc) # the exception to send in chat
print(exc.error_report) # the full report of the exception to send to a log chat or for internal log.
except ManualExecutionFail as exc:
print(exc) # the exception to send in chat
print(exc.error_report) # the full report of the exception to send to a log chat or for internal log.
except Exception as exc:
print(exc) # the exception to send in chat
##Configurations file: Must be put in a forder "configs" in the root of the project
configs/commando.cfg
[commands]
COMMANDS_DIR = commands/
[debug]
DEBUG = True
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pvlv_commando-0.0.2.tar.gz
(10.2 kB
view hashes)