Skip to content

Instantly share code, notes, and snippets.

@meskarune
Created June 11, 2019 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meskarune/fed20a414243a7ac43bbe4f30b7e0bb0 to your computer and use it in GitHub Desktop.
Save meskarune/fed20a414243a7ac43bbe4f30b7e0bb0 to your computer and use it in GitHub Desktop.
irc.conn = function (irc_config)
-- the config would need irc_config.authtype, for now I'll set it for testing
-- this could be one of nicksserve, sasl or none
local authtype = 'sasl'
if authtype == 'sasl' then
irc.connection:send(('CAP REQ :sasl\r\n'))
end
irc.connection:send(('NICK %s\r\n'):format(irc_config.handle))
irc.connection:send(('USER %s * 8 :%s\r\n'):format(irc_config.ident, irc_config.gecos))
end
-- respond to server `ACK :sasl`
irc.sasl_ack = function()
irc.connection:send(('AUTHENTICATE PLAIN\r\n'))
end
-- Respond to server `AUTHENTICATE +`
irc.authenticate = function(irc_config)
-- config will need irc_config.saslpass, or alternatively nickpass
-- setting now for testing
saslpass = 'opensesame'
local authString = ("%s\\0%s\\0%s"):format( irc_config.handle, irc_config.handle, saslpass)
local encodedString = (mime.b64(authString))
irc.connection:send(('AUTHENTICATE %s\r\n'):format(encodedString))
end
-- Respond to server `903 :SASL authentication successful`
irc.sasl_sucess = function()
irc.connection:send('CAP END\r\n')
end
++++++++++++++++++++++++++++++++++++= Throw event stuff somewhere
elseif data:find('CAP %* ACK :sasl') then
irc.sasl_ack()
elseif data:find('AUTHENTICATE %+') then
irc.authenticate(ms.config.irc)
elseif data:find(':SASL authentication successful') then
irc.sasl_sucess()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment