Added a shitload of ducks to recognize and kill!
This commit is contained in:
parent
4522289d55
commit
4ec66d2ad7
2 changed files with 16 additions and 7 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
-- | This module is an IRC plugin that generates and kills ducks
|
||||||
module Hsbot.Plugin.Duck
|
module Hsbot.Plugin.Duck
|
||||||
( duck
|
( duck
|
||||||
, theDuck
|
, theDuck
|
||||||
|
@ -12,12 +13,13 @@ import Prelude hiding (catch)
|
||||||
import Hsbot.Message
|
import Hsbot.Message
|
||||||
import Hsbot.Types
|
import Hsbot.Types
|
||||||
|
|
||||||
|
-- | The duck plugin identity
|
||||||
duck :: PluginId
|
duck :: PluginId
|
||||||
duck = PluginId
|
duck = PluginId
|
||||||
{ pluginName = "duck"
|
{ pluginName = "duck"
|
||||||
, pluginEp = theDuck }
|
, pluginEp = theDuck }
|
||||||
|
|
||||||
-- | The IrcPlugin monad main function
|
-- | An IRC plugin that generates and kills ducks
|
||||||
theDuck :: Plugin (Env IO) ()
|
theDuck :: Plugin (Env IO) ()
|
||||||
theDuck = forever $ do
|
theDuck = forever $ do
|
||||||
msg <- readMsg
|
msg <- readMsg
|
||||||
|
@ -25,14 +27,21 @@ theDuck = forever $ do
|
||||||
where
|
where
|
||||||
eval :: Message -> Plugin (Env IO) ()
|
eval :: Message -> Plugin (Env IO) ()
|
||||||
eval (IncomingMsg msg)
|
eval (IncomingMsg msg)
|
||||||
| IRC.msg_command msg == "PRIVMSG" = answerMsg msg . concat . isThereADuckToKillInThere . concat $ IRC.msg_params msg
|
| IRC.msg_command msg == "PRIVMSG" = answerMsg msg . isThereADuckToKillInThere . concat $ IRC.msg_params msg
|
||||||
| otherwise = return ()
|
| otherwise = return ()
|
||||||
eval _ = return ()
|
eval _ = return ()
|
||||||
|
|
||||||
isThereADuckToKillInThere :: String -> [String]
|
-- | Shoot as many times are there are ducks in the initial string
|
||||||
isThereADuckToKillInThere = concatMap (\y -> map (\x -> if x `L.isInfixOf` y then "PAN! " else "") ducks) . words
|
isThereADuckToKillInThere :: String -> String
|
||||||
|
isThereADuckToKillInThere = concat . concatMap (\y -> map (\x -> if x `L.isInfixOf` y then "PAN! " else "") ducks) . words
|
||||||
|
|
||||||
|
-- | There are many ways to hide as a duck, this function tries to cover most of them
|
||||||
ducks :: [String]
|
ducks :: [String]
|
||||||
ducks = ["\\_o<", "\\_O<", "\\_o>", "\\_O>", "\\o<", "\\O<", "\\o>", "\\O>",
|
ducks = [ x : y : z | x <- nose, y <- face, z <- ["__/", "_/", "/"] ]
|
||||||
">o_/", ">O_/", "<o_/", "<O_/", ">o/", ">O/", "<o/", "<O/" ]
|
++ [ L.reverse $ x : y : z | x <- nose, y <- face, z <- ["__\\", "_\\", "\\"] ]
|
||||||
|
where
|
||||||
|
nose :: [Char]
|
||||||
|
nose = "<>="
|
||||||
|
face :: [Char]
|
||||||
|
face = "oO°@©®ð*òôóø"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Name: hsbot
|
Name: hsbot
|
||||||
Version: 0.4.7
|
Version: 0.4.8
|
||||||
Cabal-version: >=1.2
|
Cabal-version: >=1.2
|
||||||
Synopsis: A multipurposes IRC bot
|
Synopsis: A multipurposes IRC bot
|
||||||
Description:
|
Description:
|
||||||
|
|
Reference in a new issue