summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2011-08-08 13:03:31 +0200
committerJulien Dessaux2011-08-08 20:58:16 +0200
commit4f50db840967c2409c9bf96c2d6525f99e39cdca (patch)
tree9f6e1372204d1e9ee3af06bbbfc6fe80bb217866
parentAdded access controls to hsbot. (diff)
downloadhsbot-4f50db840967c2409c9bf96c2d6525f99e39cdca.tar.gz
hsbot-4f50db840967c2409c9bf96c2d6525f99e39cdca.tar.bz2
hsbot-4f50db840967c2409c9bf96c2d6525f99e39cdca.zip
Fixed bad comments and some cosmetics
-rw-r--r--Hsbot/Plugin/Duck.hs2
-rw-r--r--Hsbot/Plugin/Ping.hs3
-rw-r--r--Hsbot/Utils.hs6
3 files changed, 6 insertions, 5 deletions
diff --git a/Hsbot/Plugin/Duck.hs b/Hsbot/Plugin/Duck.hs
index 946cb0c..b152685 100644
--- a/Hsbot/Plugin/Duck.hs
+++ b/Hsbot/Plugin/Duck.hs
@@ -51,7 +51,7 @@ $(makeAcidic ''StatDB ['getDuckStats, 'updateScore])
duck :: PluginId
duck = PluginId
{ pluginName = "duck"
- , pluginEp = theDuck $ DuckArgs { duckChannel = "", duckFreq = 10 } }
+ , pluginEp = theDuck DuckArgs { duckChannel = "", duckFreq = 10 } }
data DuckArgs = DuckArgs
{ duckChannel :: String
diff --git a/Hsbot/Plugin/Ping.hs b/Hsbot/Plugin/Ping.hs
index 6d28ef9..9105630 100644
--- a/Hsbot/Plugin/Ping.hs
+++ b/Hsbot/Plugin/Ping.hs
@@ -11,12 +11,13 @@ import Prelude hiding (catch)
import Hsbot.Message
import Hsbot.Types
+-- | The ping plugin identity
ping :: PluginId
ping = PluginId
{ pluginName = "ping"
, pluginEp = thePing }
--- | The IrcPlugin monad main function
+-- | An IRC plugin that answer PING requests
thePing :: Plugin (Env IO) ()
thePing = forever $ readMsg >>= eval
where
diff --git a/Hsbot/Utils.hs b/Hsbot/Utils.hs
index 912e746..2a8f58c 100644
--- a/Hsbot/Utils.hs
+++ b/Hsbot/Utils.hs
@@ -35,15 +35,15 @@ setGlobalQuitMVar status = do
liftIO $ putMVar quitMv status
-- Access rights
-hasAccess :: Maybe IRC.Prefix -> AccessRight -> Env IO (Bool)
+hasAccess :: Maybe IRC.Prefix -> AccessRight -> Env IO Bool
hasAccess Nothing _ = return False
hasAccess (Just mask) right = do
botMVar <- asks envBotState
- liftIO (readMVar botMVar) >>= evalStateT (gets botAccess >>= return . or . map accessMatch)
+ liftIO (readMVar botMVar) >>= evalStateT (fmap (any accessMatch) (gets botAccess))
where
accessMatch :: AccessList -> Bool
accessMatch (AccessList amask arights)
- | mask == amask = or [L.elem Admin arights, L.elem right arights]
+ | mask == amask = or [Admin `L.elem` arights, right `L.elem` arights]
| otherwise = False
-- Helpers