by Ahti Komu (email@example.com)
- Python (http://www.python.org/) (obviously)
- Python IRC library (http://python-irclib.sourceforge.net/)
The idea of PyPluginBot is to provide an easy pythonic way to implement
commands into a ready made bot.
A new command (a plugin) is simply a python script in a folder
named [pluginname]_plugin with a name [pluginname_plugin.py
(and of course a package placeholder __init__.py)
Plugin should implement these variables:
_cmd = "command_name"
_help = "Help text which will be shown with Bot: help [pluginname]
and a method def execute(args, e, bot) which will be executed on _cmd
said to the bot:
- args is the list of arguments passed to the command
- e is the sender (or rather, event) of the command
- bot is the bot instance (used to access mainly reply method)
Plugin can do a threaded command with method:
do_thread_command(e, cmd, args) -> the command will receive e, bot, args
Mainly the commands that are usable from the bot instance are:
do_thread_command(e, cmd, args)
This should provide easy enough way to implement new commands into
the bot in a pythonic way in just minutes.
There are also example plugins in the plugins directory including a
simple travian plugin with very hard-coded variables.
A few fixed commands are coded into the bot:
- 'help [command]': says the _help of the command
- 'commands': says the list of commands
- 'hello': says the version of the bot
- 'reload_plugins': reloads the plugins (mainly meant for plugin programmer)
There are also a few variables that have to be set before starting the bot:
self.servers : a list of tuples of servers, eg. ('de.quakenet.org', 6667)
self.nick : nick of the bot
self.realname : realname for the bot
self.channel : channel for the bot to join on connection
self.password : password for the channel that the bot joins on connection
Bear in mind that the bot is still in quite an early stage and there
might be some things that cannot be done and it may be easy to break it.
Feel free to improve it!