HOWTO 890 B

123456789101112131415161718192021
  1. Modules are loaded dynamically from this directory by the bot's load_modules function.
  2. Each module must:
  3. * Define __init__(self, events=None, printer_handle=None, bot=None)
  4. * Define a handle(self, event)
  5. So, that's a lot of work. Happily, there is a BaseModule class that defines a minimalistic (if non-functional, complete) __init__ and handle. Your module may override both, either, or neither of them. There is a convenience function, however -- post_init(). You may define an event and subscribe your module to it, then register that event with the bot.
  6. ex.
  7. youtube = Event("__.youtubes__")
  8. youtube.define(msg_definition="youtube.com[\S]+")
  9. youtube.subscribe(self)
  10. self.bot.register_event(youtube, self)
  11. Any more is gravy.
  12. An excellent example of inheriting (and how it saves you trouble) is in modules/examplederived.py.
  13. A fuller example is in example.py.