diff --git a/hooks.lua b/hooks.lua index a6e6a46..e89e92b 100644 --- a/hooks.lua +++ b/hooks.lua @@ -1,6 +1,8 @@ -- This file is licensed under the terms of the BSD 2-clause license. -- See LICENSE.txt for details. +-- MIME is part of LuaSocket +local b64e = require("mime").b64 irc.hooks = {} irc.registered_hooks = {} @@ -213,7 +215,7 @@ end function irc.hooks.preregister(conn) if not (irc.config["sasl.user"] and irc.config["sasl.pass"]) then return end - local authString = irc.b64e( + local authString = b64e( ("%s\x00%s\x00%s"):format( irc.config["sasl.user"], irc.config["sasl.user"], diff --git a/init.lua b/init.lua index 1206b49..2be1f9f 100644 --- a/init.lua +++ b/init.lua @@ -30,7 +30,6 @@ dofile(modpath.."/hooks.lua") dofile(modpath.."/callback.lua") dofile(modpath.."/chatcmds.lua") dofile(modpath.."/botcmds.lua") -dofile(modpath.."/util.lua") if irc.config.enable_player_part then dofile(modpath.."/player_part.lua") else diff --git a/util.lua b/util.lua deleted file mode 100644 index bc5b90b..0000000 --- a/util.lua +++ /dev/null @@ -1,20 +0,0 @@ ---Base 64 encode -- for SASL authentication -local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -function irc.b64e(data) - return ((data:gsub('.', function(x) - local r,b='',x:byte() - for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end - return r; - end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x) - if (#x < 6) then return '' end - local c=0 - for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end - return b:sub(c+1,c+1) - end)..({ '', '==', '=' })[#data%3+1]) -end - - --- Requested by Exio -string.expandvars = function(s, vars) - return s:gsub("%$%(([^)]+)%)", vars) -end