X-Git-Url: https://git.martlubbers.net/?p=cloogle-irc.git;a=blobdiff_plain;f=cloogle.icl;h=b2272af01a814c9116795a6e672ffa731c788da7;hp=b1303000dc9ef822275c07be4437591d44dd38b9;hb=d1b0f20fbd85d85cee19347e7deda5e3a9251906;hpb=3134ab7e61bcbc84560b4a5d613a92b1a48362c2 diff --git a/cloogle.icl b/cloogle.icl index b130300..b2272af 100644 --- a/cloogle.icl +++ b/cloogle.icl @@ -2,11 +2,11 @@ module cloogle import Cloogle import GenPrint -import IRC 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 @@ -26,12 +26,14 @@ import Data.Functor import Data.Tuple import TCPIP +import IRC +import IRCBot commands :: [String] commands = map toString [NICK "clooglebot" Nothing - ,USER "cloogle" "0" "Cloogle bot" - ,JOIN [("#cloogle", Nothing)] + ,USER "cloogle" "0" "cloogle" "Cloogle bot" + ,JOIN (CSepList ["#cloogle"]) Nothing ] TIMEOUT :== Just 10000 @@ -148,8 +150,8 @@ cloogle data w processResult (ClassResult (br, {class_name,class_funs})) = "Class in " +++ br.library +++ ": " +++ br.modul +++ "\n" +++ class_name +++ " with " +++ toString (length class_funs) +++ " class functions" - processResult (MacroResult (br, {macro_name})) - = "Macro in " +++ br.library +++ ": " +++ br.modul +++ "\n" +++ macro_name + //processResult (MacroResult (br, {macro_name})) + // = "Macro in " +++ br.library +++ ": " +++ br.modul +++ "\n" +++ macro_name processResult (ModuleResult (br, _)) = "Module in " +++ br.library +++ ": " +++ br.modul @@ -189,17 +191,19 @@ 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" - ,JOIN [("#cloogle", Nothing)]] - shutdown = map toPrefix [QUIT (Just "Bye")] + ,USER "cloogle" "cloogle" "cloogle" "Cloogle bot" + ,JOIN (CSepList ["#cloogle"]) Nothing] + 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)