diff options
Diffstat (limited to 'src/Plugin/Factorial.hs')
-rw-r--r-- | src/Plugin/Factorial.hs | 20 |
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 |