aboutsummaryrefslogtreecommitdiffstats
path: root/src/Plugin/Factorial.hs
diff options
context:
space:
mode:
authorTeddy Wing2017-09-14 03:44:38 +0200
committerTeddy Wing2017-09-14 03:44:38 +0200
commitea190de02cea99347ae125d86cc22bf8cd926c88 (patch)
tree2c5756af9a7fe86128f12117f5948282d0be4103 /src/Plugin/Factorial.hs
parentcd366dc004b82f0ea937da231cbc1c9abfdca934 (diff)
downloadsorbot-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/Factorial.hs')
-rw-r--r--src/Plugin/Factorial.hs20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/Plugin/Factorial.hs b/src/Plugin/Factorial.hs
index 9284fe7..9d7a169 100644
--- a/src/Plugin/Factorial.hs
+++ b/src/Plugin/Factorial.hs
@@ -7,20 +7,24 @@ module Plugin.Factorial
import Text.Regex.TDFA ((=~))
import TextShow (showt)
+import Bot (Bot)
import qualified Message as M
import Plugin.Base
-factorial = defaultPlugin
- { matchRegex = "^([0-9]+)!$"
- , perform = factorialAction
- , command = "<integer>!"
- , description = "Calculate the factorial of <integer> for whole numbers \
- \up to 35000."
- }
+factorial :: Bot Plugin
+factorial = do
+ return defaultPlugin
+ { matchRegex = "^([0-9]+)!$"
+ , perform = factorialAction
+ , command = "<integer>!"
+ , description = "Calculate the factorial of <integer> for whole numbers \
+ \up to 35000."
+ }
factorialAction :: PluginAction
factorialAction message = do
- case M.textStr message =~ matchRegex factorial :: [[String]] of
+ plugin <- factorial
+ case M.textStr message =~ matchRegex plugin :: [[String]] of
[] -> return $ Left "I didn't understand"
(m:_) -> do
let number = last m