Extensible XMPP Chat bot which works with https://qm.quickblox.com
Bot has its own command set. To list all available commands just send something to bot. It will answer with a list of available commands.
To get an example of the command usage enter help 'command'
All the commands are available as a part of commands module. To write new comamnd follow next steps:
- Create a new python file with a single class inherited from commands.Command and put this file inside the commands folder.
- Set the variable COMMAND_NAME to command's name
- Define the init method and set 3 fields inside: command, description, example_usage
- Define the process method. This method defines the behaviour if a new command.
- Go to init.py file inside the commands folder and add your new command to COMMANDS_DICTIONARY variable.
Use next command to run a bot:
nohup python rundoh.py &
Sometimes it's useful to automatically run a script on a Linux when it boots up. I prepared the init.d script which can be used to manage to MehDoh bot. First of all copy it to /etc/init.d/ directory on your Linux.
Then make the script executable:
sudo chmod +x /etc/init.d/mehdoh
Next you can start the mehdoh bot with this command:
sudo /etc/init.d/mehdoh start
...and stop it again with this one:
sudo /etc/init.d/mehdoh stop
In order to make the bot run on start up, it's necessary to run this command:
sudo update-rc.d mehdoh defaults
This creates a link to /etc/init.d/mehdoh in directories from /etc/rc0.d through to /etc/rc6.d. When Linux boots up or shuts down, it looks in these folders to see if any scripts or programs need to be run. When I restart my laptop the mehdoh bot starts automatically.
Here is a live working bot on https://qm.quickblox.com. Go to search box and add the user with name I am IgorK to contacts. After that you can try to use available commands.