An IRC bot in Haskell, using algebraic effects.
General refactor, mute plugin.


browse  log 



You can also use your local clone with git send-email.


An IRC bot.

#Writing a Plugin

Currently, plugins must be compiled in. Some thought is being given to having dynamically loadable plugins.

To create a plugin, make a module such as Network.LemonBot.Plugins.MyPlugin that exports a value of type Network.LemonBot.Plugins.PluginDef. This can be done in different ways depending on the kind of plugin being created.

#Command Plugins

If a plugin is only meant to provide a single shell-like command, the Network.LemonBot.Plugins.Command.commandPlugin function can greatly reduce the effort involved. This uses the the optparse-applicative library to parse a command.

For example, take Network.LemonBot.Plugins.Echo:

echoPlugin :: PluginDef
echoPlugin =
  commandPlugin "echo" configParser argParser $ \str msg -> do
    replyTo msg (BS.fromString str)
    configParser :: Decoder ()
    configParser = unit
    argParser :: Parser String
    argParser = strArgument (metavar "STR" <> help "The string to print")

This plugin may be invoked like:

07:50 <@user> !echo asdf
07:50 <lemonbot> asdf
07:50 <@user> !echo foo bar
07:50 <lemonbot> Invalid argument `bar'
07:50 <lemonbot> Usage: echo STR
07:50 <@user> !echo "foo bar"
07:50 <lemonbot> foo bar
07:50 <@user> !echo
07:50 <lemonbot> Missing: STR
07:50 <lemonbot> Usage: echo STR
07:50 <@user> !echo --help
07:50 <lemonbot> Usage: echo STR
07:50 <lemonbot> Available options:
07:50 <lemonbot>   STR                      The string to print
07:50 <lemonbot>   -h,--help                Show this help text

#Full Plugin API

If your plugin needs to do something more complicated, the full Network.LemonBot.Plugins API may be appropriate.

The PluginDef value specifies both how the plugin's config is loaded and exposes a function to create the actual Plugin value. This Plugin value gives callbacks to run when a message is received, and when the daemon is shutting down. In addition, it defines a program to be run in a separate thread.

The Network.LemonBot.Plugins.Mumble may be instructive on how to create a plugin using this API.