IrssiBot

- development -

Writing modules
The bot is written from the beginning with modularity in mind. Therefore it is possible to add features to bot via modules, which are actual compiled Java classes. Since there is this nice feature in the Java language that allows dynamic loading of classes, the bot doesn't need to be restarted when adding/removing modules. Also, the modules are each ran in their own threads, and therefore if a module crashes, the rest of the bot does not, but simply unloads the faulty module and logs the event.

So, to write a module for IrssiBot you need of course to have at least some knowledge of Java programming and be familiar with the IRC protocol and how event-based programs work. Here are the technical requirements for a Java class to meet to be a IrssiBot module:
  • It must reside in package irssibot.modules
  • It must be a subclass of AbstractModule
  • The .class file must reside in directory modules/irssibot/modules for ModuleLoader to find it.
Satisfying these conditions, the module can be loaded (either from config file or by !core->loadModule(moduleName)). It starts to receive IRC events immediately. Here are some recommended conventions to follow when writing modules:
  • All commands should have both public and /msg form. Public form must be preceded by '!'
  • The command format should be:
    • !command [argument1] [argument2] .. for public commands (said on channel)
    • /msg <botnick> command <channel> [argument1] [argument2] .. for private commads (messaged to bot)
  • All commands containing passwords etc. must NOT have a public form
  • If the module needs to keep state across bot restarts, they must do it by returning a valid Properties object in their getState() method.
  • Printouts (PRIVMSGs to either channel or nick) should be cut to minimun; for example, don't print help texts, rather than display an URL containing them. This is of course to avoid excess traffic that might slow down the bot due to slow connection to the IRC server.
  • Modules should not write to stdout/stderr. For logging purposes, use the methods in irssibot.util.log.Log.
Looking at IrssiBot API and the default modules might be the best way to start with writing modules. If you have some questions, please ask. And when you complete a module and feel it doesn't conflict with things mentioned above, zip the sources up and send them to me. I will keep some kind of archive of modules on this site. Also giving an URL to a javadoc document of the module would be nice.

Happy coding!