Fix mode command and hostnames ending with .
[cloogle-irc.git] / cloogle.icl
index b130300..b2272af 100644 (file)
@@ -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)