X-Git-Url: https://git.martlubbers.net/?p=cloogle-irc.git;a=blobdiff_plain;f=cloogle.icl;h=de1472485bfc20afe637a866a383c609673e0bcd;hp=b1303000dc9ef822275c07be4437591d44dd38b9;hb=ceec25a9ebb2fa231d68e58d05f77c449d7d7590;hpb=30b714adc7e7180d61c168c3ab7bf8090c4e8054 diff --git a/cloogle.icl b/cloogle.icl index b130300..de14724 100644 --- a/cloogle.icl +++ b/cloogle.icl @@ -7,6 +7,7 @@ import StdEnv import Data.Functor import Data.Maybe +import Data.Either from Data.Func import $ from Text import class Text(..), instance Text String, instance + String @@ -189,7 +190,7 @@ cloogle data w Start :: *World -> (MaybeErrorString (), *World) Start w = bot ("irc.freenode.net", 6667) startup shutdown () process w where - toPrefix c = {irc_prefix=Nothing,irc_command=c} + toPrefix c = {irc_prefix=Nothing,irc_command=Right c} startup = map toPrefix [NICK "clooglebot" Nothing ,USER "cloogle" "0" "Cloogle bot" @@ -197,9 +198,11 @@ Start w = bot ("irc.freenode.net", 6667) startup shutdown () process w shutdown = map toPrefix [QUIT (Just "Bye")] process :: IRCMessage () *World -> (Maybe [IRCMessage], (), *World) - process im s w = case process` im.irc_command w of - (Nothing, w) = (Nothing, (), w) - (Just cs, w) = (Just $ map toPrefix cs, (), w) + process im s w = case im.irc_command of + Left numr = (Just [], (), w) + Right cmd = case process` cmd w of + (Nothing, w) = (Nothing, (), w) + (Just cs, w) = (Just $ map toPrefix cs, (), w) process` :: IRCCommand *World -> (Maybe [IRCCommand], *World) process` (PRIVMSG t m) w = (Just $ if (startsWith "!" m)