Added optional SASL. take that darkf
This commit is contained in:
parent
45ab816815
commit
71f92b839e
33
irc.lamb
33
irc.lamb
|
@ -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) ->
|
||||
|
|
Loading…
Reference in New Issue