From 2d94eb37d15032636acb08af43e3c5906bedcc45 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 20 Aug 2017 00:14:46 +0200 Subject: Add Help plugin A new plugin that displays a help listing for every plugin in the bot. Currently the formatting is off in the chat output, but it does work. This introduces two new record fields on `Plugin`: `command` and `description`. The command is the text used to invoke the plugin and the description is a long form explanation of what the plugin does. Needed to update the `Show` for `Plugin` to match these extra fields. Didn't change any of the output for now because I'm not really using the `show` function, so I don't need to see the new fields for now. Also change the `p` argument to an `_` because we're not using it. All existing plugins now have the new fields filled. The Help plugin will go through the list of all plugins and get their help fields for output. In order to be able to use the plugin list in both `Plugin.hs` and in the Help plugin module, I needed to move the list into a new module to avoid a circular dependency. Previously the `Plugin` module defined the list, but we can't import `Plugin` from `Help` because `Plugin` needs to import `Help` in order to build the full list of plugins. The semi-hackish solution I came up with was to create a new module for the plugin list that both these modules can use, but leave out the `Help` plugin from the plugin list there. Then, `Plugin` and `Help` override the list, appending the `Help` plugin to the list. I want the Help plugin to appear last, which is why I'm appending. Wasn't comfortable concatenating the list because of the performance smell, but it's going to be a small enough list anyway that it shouldn't be a problem. One thing I don't really like is the fact that we have to return an `IO a` from `helpAction` even though it doesn't interact with `IO` at all. Not sure if there's a way to use `IO` when we need it and not when we don't. Not a huge deal though. --- sorbot.cabal | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sorbot.cabal') diff --git a/sorbot.cabal b/sorbot.cabal index 69ef437..62de431 100644 --- a/sorbot.cabal +++ b/sorbot.cabal @@ -24,6 +24,8 @@ library , Plugin.Base , Plugin.GitHubCommit , Plugin.GitRemoteSetOrigin + , Plugin.Help + , Plugin.PluginList build-depends: base >= 4.7 && < 5 , bytestring , irc-client -- cgit v1.2.3