Fixed bad comments and some cosmetics
This commit is contained in:
parent
1c8cab09cb
commit
4f50db8409
3 changed files with 6 additions and 5 deletions
|
@ -51,7 +51,7 @@ $(makeAcidic ''StatDB ['getDuckStats, 'updateScore])
|
||||||
duck :: PluginId
|
duck :: PluginId
|
||||||
duck = PluginId
|
duck = PluginId
|
||||||
{ pluginName = "duck"
|
{ pluginName = "duck"
|
||||||
, pluginEp = theDuck $ DuckArgs { duckChannel = "", duckFreq = 10 } }
|
, pluginEp = theDuck DuckArgs { duckChannel = "", duckFreq = 10 } }
|
||||||
|
|
||||||
data DuckArgs = DuckArgs
|
data DuckArgs = DuckArgs
|
||||||
{ duckChannel :: String
|
{ duckChannel :: String
|
||||||
|
|
|
@ -11,12 +11,13 @@ import Prelude hiding (catch)
|
||||||
import Hsbot.Message
|
import Hsbot.Message
|
||||||
import Hsbot.Types
|
import Hsbot.Types
|
||||||
|
|
||||||
|
-- | The ping plugin identity
|
||||||
ping :: PluginId
|
ping :: PluginId
|
||||||
ping = PluginId
|
ping = PluginId
|
||||||
{ pluginName = "ping"
|
{ pluginName = "ping"
|
||||||
, pluginEp = thePing }
|
, pluginEp = thePing }
|
||||||
|
|
||||||
-- | The IrcPlugin monad main function
|
-- | An IRC plugin that answer PING requests
|
||||||
thePing :: Plugin (Env IO) ()
|
thePing :: Plugin (Env IO) ()
|
||||||
thePing = forever $ readMsg >>= eval
|
thePing = forever $ readMsg >>= eval
|
||||||
where
|
where
|
||||||
|
|
|
@ -35,15 +35,15 @@ setGlobalQuitMVar status = do
|
||||||
liftIO $ putMVar quitMv status
|
liftIO $ putMVar quitMv status
|
||||||
|
|
||||||
-- Access rights
|
-- Access rights
|
||||||
hasAccess :: Maybe IRC.Prefix -> AccessRight -> Env IO (Bool)
|
hasAccess :: Maybe IRC.Prefix -> AccessRight -> Env IO Bool
|
||||||
hasAccess Nothing _ = return False
|
hasAccess Nothing _ = return False
|
||||||
hasAccess (Just mask) right = do
|
hasAccess (Just mask) right = do
|
||||||
botMVar <- asks envBotState
|
botMVar <- asks envBotState
|
||||||
liftIO (readMVar botMVar) >>= evalStateT (gets botAccess >>= return . or . map accessMatch)
|
liftIO (readMVar botMVar) >>= evalStateT (fmap (any accessMatch) (gets botAccess))
|
||||||
where
|
where
|
||||||
accessMatch :: AccessList -> Bool
|
accessMatch :: AccessList -> Bool
|
||||||
accessMatch (AccessList amask arights)
|
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
|
| otherwise = False
|
||||||
|
|
||||||
-- Helpers
|
-- Helpers
|
||||||
|
|
Reference in a new issue