commands :: [String]
commands = map toString
- [NICK "clooglebot"
- ,USER "cloogle" 0 "Cloogle bot"
+ [NICK "clooglebot" Nothing
+ ,USER "cloogle" "0" "Cloogle bot"
,JOIN [("#cloogle", Nothing)]
]
# 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/#" + urlEncode data + "\n" +
+ Just clr = ("Results for " + data + " -- https://cloogle.org/#" + replaceSubString "+" "%20" (urlEncode data) + "\n" +
processResults clr, w)
where
processResults :: Response -> String
processResult :: Result -> String
processResult (FunctionResult (br, {func}))
- = "Function in " +++ br.library +++ ": " +++ br.modul +++ " - " +++ func
+ = "Function in " +++ br.library +++ ": " +++ br.modul +++ "\n" +++ func
processResult (TypeResult (br, {type}))
- = "Type in " +++ br.library +++ ": " +++ br.modul +++ " - " +++ limitResults type
+ = "Type in " +++ br.library +++ ": " +++ br.modul +++ "\n" +++ limitResults type
processResult (ClassResult (br, {class_name,class_funs}))
- = "Class in " +++ br.library +++ ": " +++ br.modul +++ " - " +++ class_name +++ " with "
+ = "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 +++ " - " +++ macro_name
+ = "Macro in " +++ br.library +++ ": " +++ br.modul +++ "\n" +++ macro_name
processResult (ModuleResult (br, _))
= "Module in " +++ br.library +++ ": " +++ br.modul
send :: [String] TCP_DuplexChannel *World -> (TCP_DuplexChannel, *World)
send [] chan w = (chan, w)
send [msg:msgs] {sChannel,rChannel} w
+# (_, w) = sleep 250000 w
# (rpt,i,sChannel,w) = send_MT TIMEOUT (toByteSeq msg) sChannel w
| rpt <> TR_Success = abort "Could not send request\n"
= send msgs {sChannel=sChannel,rChannel=rChannel} w
+ where
+ sleep :: !Int !*World -> (!Int, *World)
+ sleep i w = code {
+ ccall usleep "I:I:A"
+ }
recv :: TCP_DuplexChannel *World -> (Maybe String, TCP_DuplexChannel, *World)
recv {sChannel,rChannel} w
| rpt == TR_NoSuccess || isNothing resp = abort "Halp?\n"
= (toString <$> resp, {sChannel=sChannel,rChannel=rChannel}, w)
-msg :: (String -> IRCCommands)
-msg = PRIVMSG "#cloogle"
+msg :: (String -> IRCCommand)
+msg = PRIVMSG ["#cloogle"]
process :: *File TCP_DuplexChannel *World -> (*File, TCP_DuplexChannel, *World)
process io chan w