diff options
author | Julien Dessaux | 2011-05-05 00:30:34 +0200 |
---|---|---|
committer | Julien Dessaux | 2011-05-05 00:30:34 +0200 |
commit | 9abbc593a2dada91aaeabe092a19089111f6ab40 (patch) | |
tree | f84c34dc35c04cde0749aa70d0d060b3640e79e1 /Hsbot/Plugin | |
parent | Updated for TLS 0.6 (diff) | |
download | hsbot-9abbc593a2dada91aaeabe092a19089111f6ab40.tar.gz hsbot-9abbc593a2dada91aaeabe092a19089111f6ab40.tar.bz2 hsbot-9abbc593a2dada91aaeabe092a19089111f6ab40.zip |
Added the Duck module (PAN!).
Diffstat (limited to '')
-rw-r--r-- | Hsbot/Plugin/Duck.hs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Hsbot/Plugin/Duck.hs b/Hsbot/Plugin/Duck.hs new file mode 100644 index 0000000..5b4371e --- /dev/null +++ b/Hsbot/Plugin/Duck.hs @@ -0,0 +1,38 @@ +module Hsbot.Plugin.Duck + ( duck + , theDuck + ) where + +import Control.Concurrent.Chan () +import qualified Data.List as L +import Control.Monad.State +import qualified Network.IRC as IRC +import Prelude hiding (catch) + +import Hsbot.Message +import Hsbot.Types + +duck :: PluginId +duck = PluginId + { pluginName = "duck" + , pluginEp = theDuck } + +-- | The IrcPlugin monad main function +theDuck :: Plugin (Env IO) () +theDuck = forever $ do + msg <- readMsg + eval msg + where + eval :: Message -> Plugin (Env IO) () + eval (IncomingMsg msg) + | IRC.msg_command msg == "PRIVMSG" = answerMsg msg . concat . isThereADuckToKillInThere . concat $ IRC.msg_params msg + | otherwise = return () + eval _ = return () + +isThereADuckToKillInThere :: String -> [String] +isThereADuckToKillInThere = concatMap (\y -> map (\x -> if x `L.isInfixOf` y then "PAN! " else "") ducks) . words + +ducks :: [String] +ducks = ["\\_o<", "\\_O<", "\\_o>", "\\_O>", "\\o<", "\\O<", "\\o>", "\\O>", + ">o_/", ">O_/", "<o_/", "<O_/", ">o/", ">O/", "<o/", "<O/" ] + |