summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2012-03-07 22:01:13 +0100
committerJulien Dessaux2012-03-07 22:20:44 +0100
commit619fbe97565fd7220b08f2522aaf359f10a0239e (patch)
tree020ce4c6ffc3dbcc4e2a1098faaad8c62c7b40a2
parentAdded arguments handling for the quote module (diff)
downloadhsbot-619fbe97565fd7220b08f2522aaf359f10a0239e.tar.gz
hsbot-619fbe97565fd7220b08f2522aaf359f10a0239e.tar.bz2
hsbot-619fbe97565fd7220b08f2522aaf359f10a0239e.zip
Added db name argument to the duck module.
-rw-r--r--Hsbot/Plugin/Duck.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/Hsbot/Plugin/Duck.hs b/Hsbot/Plugin/Duck.hs
index c0da0c6..0f2fd80 100644
--- a/Hsbot/Plugin/Duck.hs
+++ b/Hsbot/Plugin/Duck.hs
@@ -2,6 +2,7 @@
-- | This module is an IRC plugin that generates and kills ducks
module Hsbot.Plugin.Duck
( DuckArgs (..)
+ , defaultDuckArgs
, duck
, theDuck
) where
@@ -52,17 +53,21 @@ $(makeAcidic ''StatDB ['getDuckStats, 'updateScore])
duck :: PluginId
duck = PluginId
{ pluginName = "duck"
- , pluginEp = theDuck DuckArgs { duckChannel = "", duckFreq = 10 } }
+ , pluginEp = theDuck defaultDuckArgs }
data DuckArgs = DuckArgs
{ duckChannel :: String
+ , duckDbName :: String
, duckFreq :: Int }
+defaultDuckArgs :: DuckArgs
+defaultDuckArgs = DuckArgs { duckChannel = "", duckDbName = "duckDB", duckFreq = 7200 }
+
-- | An IRC plugin that generates and kills ducks
theDuck :: DuckArgs -> Plugin (Env IO) ()
-theDuck (DuckArgs channel seconds) = do
+theDuck (DuckArgs channel dbName seconds) = do
baseDir <- liftIO $ System.Environment.XDG.BaseDir.getUserDataDir "hsbot"
- statDB <- liftIO $ openLocalStateFrom (baseDir ++ "/duckDB/") emptyStatDB
+ statDB <- liftIO $ openLocalStateFrom (baseDir ++ "/" ++ dbName ++ "/") emptyStatDB
ducksMVar <- liftIO newEmptyMVar
timeMVar <- liftIO $ newMVar seconds
duckSpawner channel seconds ducksMVar