-bot :: (String, Int) [IRCMessage] [IRCMessage] .a (IRCMessage *(.a, *World) -> *(Maybe [IRCMessage], (.a, *World))) *World -> *(Maybe String, *(.a, *World))
+bot :: (String, Int) [IRCMessage] [IRCMessage] .a (IRCMessage -> (.a -> .(*World -> *(Maybe [IRCMessage], .a, *World)))) *World -> *(Maybe String, .a, *World)
bot (host, port) start end state bot w
//Lookup hostname
# (ip, w) = lookupIPAddress host w
| isNothing ip
bot (host, port) start end state bot w
//Lookup hostname
# (ip, w) = lookupIPAddress host w
| isNothing ip
//Connect
# (rpt,chan,w) = connectTCP_MT TIMEOUT (fromJust ip, port) w
| rpt == TR_Expired
//Connect
# (rpt,chan,w) = connectTCP_MT TIMEOUT (fromJust ip, port) w
| rpt == TR_Expired
//Start processing function
# (mer, chan, state, w) = process chan "" state bot w
//Start processing function
# (mer, chan, state, w) = process chan "" state bot w
// Send shutdown commands
# (merr, {rChannel,sChannel}, w) = send (map toString end) chan w
// Send shutdown commands
# (merr, {rChannel,sChannel}, w) = send (map toString end) chan w
-process :: TCP_DuplexChannel String .a (IRCMessage (.a, *World) -> (Maybe [IRCMessage], (.a, *World))) *World -> (MaybeErrorString (), TCP_DuplexChannel, (.a, *World))
+process :: TCP_DuplexChannel String .a (IRCMessage -> (.a -> .(*World -> *(Maybe [IRCMessage], .a, *World)))) *World -> (MaybeErrorString (), TCP_DuplexChannel, .a, *World)
process chan acc state bot w
//See if we have a message
= case split "\r\n" acc of
process chan acc state bot w
//See if we have a message
= case split "\r\n" acc of
- | isError merr_resp = (Error (fromError merr_resp), chan, (state, w))
+ | isError merr_resp = (Error (fromError merr_resp), chan, state, w)
//We have a successfull split and therefore we process at least one message
[m:xs]
# acc = join "\r\n" xs
= case parseIRCMessage $ m +++ "\r\n" of
(Left err) = (Error $ "IRC Parsing error: " +++ join "\n" err, chan, state, w)
(Right msg)
//We have a successfull split and therefore we process at least one message
[m:xs]
# acc = join "\r\n" xs
= case parseIRCMessage $ m +++ "\r\n" of
(Left err) = (Error $ "IRC Parsing error: " +++ join "\n" err, chan, state, w)
(Right msg)
- # (mircc, state, w) = bot msg (state, w)
- | isNothing mircc = (Ok (), chan, (state, w)) // Bot asks to quit
+ # (mircc, state, w) = bot msg state w
+ | isNothing mircc = (Ok (), chan, state, w) // Bot asks to quit
//Possible send the commands
# (merr, chan, w) = send (map toString $ fromJust mircc) chan w
//Possible send the commands
# (merr, chan, w) = send (map toString $ fromJust mircc) chan w
- | isError merr = (Error $ fromError merr, chan, (state, w))
+ | isError merr = (Error $ fromError merr, chan, state, w)
send [msg:msgs] {sChannel,rChannel} 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 [msg:msgs] {sChannel,rChannel} 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)
recv :: TCP_DuplexChannel *World -> (MaybeErrorString (Maybe String), TCP_DuplexChannel, *World)
recv {sChannel,rChannel} w
recv :: TCP_DuplexChannel *World -> (MaybeErrorString (Maybe String), TCP_DuplexChannel, *World)
recv {sChannel,rChannel} w