summaryrefslogtreecommitdiff
path: root/Hsbot/Plugin
diff options
context:
space:
mode:
authorJulien Dessaux2011-06-17 13:08:33 +0200
committerJulien Dessaux2011-06-17 13:08:33 +0200
commit8fae43453245bdc683e64957b9499423b8825e7b (patch)
treeba9a9c06a7c1e6e207e8b64f00032ffc35cec287 /Hsbot/Plugin
parentFixed a bug in command parsing (diff)
downloadhsbot-8fae43453245bdc683e64957b9499423b8825e7b.tar.gz
hsbot-8fae43453245bdc683e64957b9499423b8825e7b.tar.bz2
hsbot-8fae43453245bdc683e64957b9499423b8825e7b.zip
Improved the duck plugin arguments handling
Diffstat (limited to 'Hsbot/Plugin')
-rw-r--r--Hsbot/Plugin/Duck.hs13
1 files changed, 9 insertions, 4 deletions
diff --git a/Hsbot/Plugin/Duck.hs b/Hsbot/Plugin/Duck.hs
index 4b05982..7ba2146 100644
--- a/Hsbot/Plugin/Duck.hs
+++ b/Hsbot/Plugin/Duck.hs
@@ -1,7 +1,8 @@
{-# LANGUAGE TypeFamilies, DeriveDataTypeable, TemplateHaskell #-}
-- | This module is an IRC plugin that generates and kills ducks
module Hsbot.Plugin.Duck
- ( duck
+ ( DuckArgs (..)
+ , duck
, theDuck
) where
@@ -50,11 +51,15 @@ $(makeAcidic ''StatDB ['getDuckStats, 'updateScore])
duck :: PluginId
duck = PluginId
{ pluginName = "duck"
- , pluginEp = theDuck "" 10 }
+ , pluginEp = theDuck $ DuckArgs { duckChannel = "", duckFreq = 10 } }
+
+data DuckArgs = DuckArgs
+ { duckChannel :: String
+ , duckFreq :: Int }
-- | An IRC plugin that generates and kills ducks
-theDuck :: String -> Int -> Plugin (Env IO) ()
-theDuck channel seconds = do
+theDuck :: DuckArgs -> Plugin (Env IO) ()
+theDuck (DuckArgs channel seconds) = do
baseDir <- liftIO $ System.Environment.XDG.BaseDir.getUserDataDir "hsbot"
statDB <- liftIO $ openAcidStateFrom (baseDir ++ "/duckDB/") emptyStatDB
ducksMVar <- liftIO newEmptyMVar