We probably also want the syntax sugar exported by Bot::Cobalt. This provides a simpler function interface to common core methods; we'll be able to call broadcast() to relay events and logger() to log messages.

Our plugin can't be loaded unless it can handle Cobalt_register and Cobalt_unregister events. It's also probably not very useful unless it's registered to receive some kind of event, most often from Bot::Cobalt::IRC.

Let's register to receive the in-channel command 'fortune' -- we'll figure out some responses to it later. Since we 'use Bot::Cobalt' we have the register() and logger() functions available:

Notice the PLUGIN_EAT_NONE? Our event handlers should always return a Object::Pluggable::Constants constant indicating what to do with the event after the handler is complete. This is typically one of PLUGIN_EAT_NONE or PLUGIN_EAT_ALL, indicating whether to let the event continue on down the pipeline or be terminated, respectively.

Now we're loadable and will register to receive the 'SERVER' event public_cmd_fortune -- we just need a handler for it.

The first argument after the $self and $core objects will be a reference to a Bot::Cobalt::IRC::Message::Public object. We'll de-reference it and call some common methods to find out what we want to know.