From 4f50db840967c2409c9bf96c2d6525f99e39cdca Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Mon, 8 Aug 2011 13:03:31 +0200 Subject: Fixed bad comments and some cosmetics --- Hsbot/Plugin/Duck.hs | 2 +- Hsbot/Plugin/Ping.hs | 3 ++- Hsbot/Utils.hs | 6 +++--- 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 -- cgit v1.2.3