send :: [String] TCP_DuplexChannel *World -> (MaybeErrorString (), TCP_DuplexChannel, *World)
send [] chan w = (Ok (), chan, w)
send [msg:msgs] {sChannel,rChannel} w
-# (_, w) = sleep 250000 w
+# (_, w) = sleep 500000 w
# (rpt,i,sChannel,w) = send_MT TIMEOUT (toByteSeq msg) sChannel w
| rpt <> TR_Success = (Error "Could not send message", {sChannel=sChannel,rChannel=rChannel}, w)
= send msgs {sChannel=sChannel,rChannel=rChannel} w
import IRC
import IRCBot
-commands :: [String]
-commands = map toString
- [NICK "clooglebot" Nothing
- ,USER "cloogle" "0" "cloogle" "Cloogle bot"
- ,JOIN (CSepList ["#cloogle"]) Nothing
- ]
-
TIMEOUT :== Just 10000
SERVER :== "irc.freenode.net"
-KEY :== "PRIVMSG #cloogle :!"
-
doRequest :: HTTPRequest *World -> *(MaybeErrorString HTTPResponse, *World)
doRequest req w
# (ip,w) = lookupIPAddress server_name w
# resp = fromOk mer
= case fromJSON $ fromString resp.HTTPResponse.rsp_data of
Nothing = ("couldn't parse json", w)
- Just clr = ("Results for " + data + " -- https://cloogle.org/#" + replaceSubString "+" "%20" (urlEncode data) + "\n" +
- processResults clr, w)
+ Just clr = ("Results for " + data + " -- https://cloogle.org/#" +
+ replaceSubString "+" "%20" (urlEncode data) + "\n" +
+ processResults clr, w)
where
processResults :: Response -> String
processResults resp
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 (ModuleResult (br, _))
= "Module in " +++ br.library +++ ": " +++ br.modul
startup = map toPrefix
[NICK "clooglebot" Nothing
,USER "cloogle" "cloogle" "cloogle" "Cloogle bot"
- ,JOIN (CSepList ["#cloogle"]) Nothing]
+ ,JOIN (CSepList ["#cloogle", "#cleanlang"]) Nothing]
shutdown = map toPrefix [QUIT $ Just "Bye"]
process :: IRCMessage () *World -> (Maybe [IRCMessage], (), *World)
| m.[0] == '!'
# (msgs, w) = realProcess (split " " $ m % (1, size m)) w
= (Just $ map (PRIVMSG t) msgs, w)
- = (Nothing, w)
+ = (Just [], w)
process` (PING t mt) w = (Just [PONG t mt], w)
process` _ w = (Just [], w)
), w)
realProcess ["help"] w = (
["Type !help cmd for command specific help"
- ,"available commands: help, ping, shorten, query"], w)
+ ,"available commands: help, ping, shorten, query, restart"], w)
realProcess ["ping":xs] w = (["pong " +++ join " " xs], w)
realProcess ["shorten":xs] w = case xs of
[] = (["shorten requires at least one argument"], w)
xs = mapSt shorten xs w
realProcess ["query":xs] w = case xs of
[] = (["query requires one or more arguments"], w)
- xs = (["Not implemented yet..."], w)
+ xs = appFst (split "\n") $ cloogle (join " " xs) w
realProcess ["restart"] w = abort "Restarted"
realProcess ["restart":_] w = (["restart takes no arguments"], w)
realProcess [c:_] w = ([join " " [