diff options
author | Teddy Wing | 2017-09-14 03:44:38 +0200 |
---|---|---|
committer | Teddy Wing | 2017-09-14 03:44:38 +0200 |
commit | ea190de02cea99347ae125d86cc22bf8cd926c88 (patch) | |
tree | 2c5756af9a7fe86128f12117f5948282d0be4103 /src/Plugin/Help.hs | |
parent | cd366dc004b82f0ea937da231cbc1c9abfdca934 (diff) | |
download | sorbot-ea190de02cea99347ae125d86cc22bf8cd926c88.tar.bz2 |
Add `Bot` to rest of plugins
Add our `Bot` monad to the rest of the plugins:
* Factorial
* GitRemoteSetOrigin
* Help
The only problem is with the Help plugin. Still trying to figure out how
to set up my list comprehension so that it works with the `Bot`-wrapped
`Plugin` list.
Diffstat (limited to 'src/Plugin/Help.hs')
-rw-r--r-- | src/Plugin/Help.hs | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/Plugin/Help.hs b/src/Plugin/Help.hs index 63143b1..b29d1b9 100644 --- a/src/Plugin/Help.hs +++ b/src/Plugin/Help.hs @@ -4,28 +4,36 @@ module Plugin.Help ( help ) where +import Control.Monad (sequence) import qualified Data.Text as T +import Bot (Bot) import qualified PluginList as PL (plugins) import Plugin.Base -help = defaultPlugin - { matchRegex = "^help$" - , perform = helpAction - , command = "help" - , description = "Show a list of available bot commands." - , queryOnly = True - } +help :: Bot Plugin +help = do + return defaultPlugin + { matchRegex = "^help$" + , perform = helpAction + , command = "help" + , description = "Show a list of available bot commands." + , queryOnly = True + } helpAction :: PluginAction helpAction _ = do return $ Right $ T.intercalate "\n" - [T.justifyRight longestCommandLen ' ' (command p) - `T.append` " – " - `T.append` description p - | p <- plugins] + -- [T.justifyRight longestCommandLen ' ' (command p) + -- `T.append` " – " + -- `T.append` description p + -- | p <- plugins'] where longestCommandLen = foldr (max) 0 (map (T.length . command) plugins) -plugins :: [Plugin] + helpText plugin = T.justifyRight longestCommandLen ' ' (command plugin) + `T.append` " – " + `T.append` description plugin + +plugins :: [Bot Plugin] plugins = PL.plugins ++ [help] |