Added optional SASL. take that darkf

This commit is contained in:
Nicholas Chambers 2017-06-22 05:20:43 +01:00
parent 45ab816815
commit 71f92b839e
1 changed files with 13 additions and 20 deletions

View File

@ -276,12 +276,13 @@ handleCommand(s, _, "AUTHENTICATE", ["+"]) -> do
s
end.
registering_finished = ref!(false).
handleCommand(s, _, "903", _) -> do
putstrln("SASL authentication successful.");
fputstr(sock, "CAP END\r\n");
setRef!(registering_finished, true);
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();
s
end.
@ -308,29 +309,21 @@ 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, readRef!(registering_finished) == false) then do
line = fgetline(sock);
handleLine(state, line);
putstrln(repr(readRef!(registering_finished)))
end
else false.
-- send introduction
if config\PASS != "" then
if config\SASL == true then do
fputstr(sock, "CAP REQ :sasl\r\n");
loop(registerLoop, [])
end
if config\SASL == true then
fputstr(sock, "CAP REQ :sasl\r\n")
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().
if config\SASL == false 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 (,).
-- loop receiving lines
mainloop(state) ->