diff options
Diffstat (limited to 'HsBot/Base/Cmd.hs')
| -rw-r--r-- | HsBot/Base/Cmd.hs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/HsBot/Base/Cmd.hs b/HsBot/Base/Cmd.hs new file mode 100644 index 0000000..c4963ac --- /dev/null +++ b/HsBot/Base/Cmd.hs @@ -0,0 +1,16 @@ +module HsBot.Base.Cmd where + +import HsBot.Base.State + +data Cmd = Cmd String String (State -> IO ()) + +instance Show Cmd where + show (Cmd a b _) = a ++ " - " ++ b + +cmdGet :: String -> [Cmd] -> Maybe Cmd +cmdGet x commands = + let command = [ (Cmd a b c) | (Cmd a b c) <- commands, a == x ] + in if length command == 0 + then Nothing + else Just (head command) + |
