blob: ac38dab07dcc81813bc0061d19a935311b85158c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
{-# LANGUAGE OverloadedStrings #-}
module Plugin.Help
( help
) where
import qualified Data.Text as T
import qualified PluginList as PL (plugins)
import Plugin.Base
help = Plugin
{ matchRegex = "^help$"
, perform = helpAction
, command = "help"
, description = "Show a list of available bot commands."
}
helpAction :: PluginAction
helpAction _ = do
return $ Right $ T.intercalate "\n"
[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]
plugins = PL.plugins ++ [help]
|