lambot has a syntax error
nchambers@spectre:~/lambot$ lamb irc.lamb lamb: ParseError (LocPos (SrcPos {locFile = "<input>", locAbs = 7924, locLine = 319, locCol = 1})) "unexpected input" CallStack (from HasCallStack): error, called at ./Interp.hs:528:29 in main:Interp nchambers@spectre:~/lambot$
This commit is contained in:
parent
9e78e6f97d
commit
5f607d8d31
46
irc.lamb
46
irc.lamb
|
@ -2,6 +2,7 @@ import("std/base64").
|
|||
import("std/list").
|
||||
import("std/str").
|
||||
import("std/http").
|
||||
import("std/op").
|
||||
import("config").
|
||||
|
||||
-- the lexical environment that $eval uses
|
||||
|
@ -265,25 +266,28 @@ handleCommand(s, _, "366", _) -> s. -- End of NAMES list
|
|||
|
||||
handleCommand(s, _, "CAP", ["*", "ACK", "sasl "]) -> do
|
||||
putstrln("Starting SASL handshake.");
|
||||
fputstr(sock, "AUTHENTICATE PLAIN\r\n")
|
||||
fputstr(sock, "AUTHENTICATE PLAIN\r\n");
|
||||
s
|
||||
end.
|
||||
|
||||
handleCommand(s, _, "AUTHENTICATE", ["+"]) -> do
|
||||
auth = base64\base64_encode(config\NICK + "\0" + config\NICK + "\0" + config\PASS);
|
||||
fputstr(sock, "AUTHENTICATE " + auth + "\r\n")
|
||||
fputstr(sock, "AUTHENTICATE " + auth + "\r\n");
|
||||
s
|
||||
end.
|
||||
|
||||
registering_finished = false.
|
||||
|
||||
handleCommand(s, _, "903", _) -> do
|
||||
putstrln("SASL authentication successful.");
|
||||
fputstr(sock, "CAP END\r\n");
|
||||
fputstr(sock, "NICK " + config\NICK + "\r\n");
|
||||
fputstr(sock, "USER " + config\NICK + " 0 * :Lamb Da. Bot\r\n");
|
||||
joinChans() -> list\map(\chan -> fputstr(sock, "JOIN " + chan + "\r\n"), config\CHANS);
|
||||
joinChans()
|
||||
registering_finished = true;
|
||||
s
|
||||
end.
|
||||
|
||||
handleCommand(s, src, cmd, args) -> do
|
||||
putstrln("Unhandled command: " + cmd + ", with args: " + repr(args) + " from " + src)
|
||||
putstrln("Unhandled command: " + cmd + ", with args: " + repr(args) + " from " + src);
|
||||
s
|
||||
end.
|
||||
|
||||
handleLine(s, ":" :: line) -> do
|
||||
|
@ -304,16 +308,26 @@ end.
|
|||
-- build our socket and connect to the server
|
||||
sock = sockopen(config\HOST, config\PORT).
|
||||
|
||||
-- SASL register loop
|
||||
registerLoop(state) ->
|
||||
if op\and(feof(sock) != true, finished_registering == false) then do
|
||||
line = fgetline(state, line)
|
||||
end
|
||||
else false.
|
||||
|
||||
-- send introduction
|
||||
if config\PASS == "" then do
|
||||
fputstr(sock, "NICK " + config\NICK + "\r\n");
|
||||
fputstr(sock, "USER " + config\NICK + " 0 * :Lamb Da. Bot\r\n");
|
||||
joinChans() -> list\map(\chan -> fputstr(sock, "JOIN " + chan + "\r\n"), config\CHANS);
|
||||
joinChans()
|
||||
end
|
||||
else do
|
||||
fputstr(sock, "CAP REQ :sasl\r\n")
|
||||
end.
|
||||
if config\PASS != "" then
|
||||
if config\SASL == true then
|
||||
fputstr(sock, "CAP REQ :sasl\r\n")
|
||||
loop(registerLoop, [])
|
||||
else
|
||||
fputstr(sock, "PASS " + config\PASS + "\r\n")
|
||||
else (,).
|
||||
|
||||
fputstr(sock, "NICK " + config\NICK + "\r\n").
|
||||
fputstr(sock, "USER " + config\NICK + " 0 * :Lamb Da. Bot\r\n").
|
||||
joinChans() -> list\map(\chan -> fputstr(sock, "JOIN " + chan + "\r\n"), config\CHANS).
|
||||
joinChans().
|
||||
|
||||
-- loop receiving lines
|
||||
mainloop(state) ->
|
||||
|
|
Loading…
Reference in New Issue