Skip to content

How to create a plugin

Daniel Kontsek edited this page Apr 17, 2015 · 22 revisions

First, make sure you have got your [Ludolph bot installed and configured](How to install and configure Ludolph)


Create core plugin

XMPP Extensions can be built into Ludolph core.

  1. In the ludolph/plugins directory create new file with the name of your plugin, e.g. sample.py

  2. Inside that directory create a class with the same name as your file; it has to be a child of the LudolphPlugin class

     from ludolph.plugins.plugin import LudolphPlugin
    
     class Sample(LudolphPlugin):
         ...
    
  3. Each function with the @command decorator will be a Ludolph command

  4. Add a new section (it can be empty) named after your plugin file into the Ludolph configuration file; e.g. [sample]

  5. After reloading Ludolph you can use your plugin (check the log file in case of problems)

Create 3rd party plugin

Other extensions can be created as 3rd party plugin. Creating a 3rd party plugin is almost the same as creating a core plugin. Minor difference is that when registering with Ludolph configuration file use the whole python path for the section name (like a python import); e.g. [thirdparty.plugin.sample]

We have prepared a ludolph-plugin-skeleton repository that contains the ludolph-hello-world plugin. Skeleton has a structure of a pip installable application (for ludolph-hello-world installation see the repository README file). It contains a plugin with three sample commands, each using a different decorators for sample usage.

Clone this wiki locally