diff --git a/other_things/irc-old-save/botcmds.lua b/other_things/irc-old-save/botcmds.lua index 44077407..34978a87 100755 --- a/other_things/irc-old-save/botcmds.lua +++ b/other_things/irc-old-save/botcmds.lua @@ -46,13 +46,13 @@ function irc:bot_command(msg, text) cmd = text args = "" end - + if not self.bot_commands[cmd] then self:reply("Unknown command '"..cmd.."'. Try 'list'." .." Or use @playername to send a private message") return end - + local success, message = self.bot_commands[cmd].func(msg.user, args) if message then self:reply(message) diff --git a/other_things/irc-old-save/core.so b/other_things/irc-old-save/core.so deleted file mode 100755 index 41fb027a..00000000 Binary files a/other_things/irc-old-save/core.so and /dev/null differ diff --git a/other_things/irc-old-save/hooks.lua b/other_things/irc-old-save/hooks.lua index c27ba5d9..6c8e2438 100755 --- a/other_things/irc-old-save/hooks.lua +++ b/other_things/irc-old-save/hooks.lua @@ -1,28 +1,12 @@ -- This file is licensed under the terms of the BSD 2-clause license. -- See LICENSE.txt for details. -local ie = ... - -- MIME is part of LuaSocket -local b64e = ie.require("mime").b64 +local b64e = require("mime").b64 irc.hooks = {} irc.registered_hooks = {} -local accent_chars = { {"À", "A"},{"Á", "A"},{"Â", "A"},{"Ã", "A"},{"Ä", "A"},{"Å", "A"},{"Ç", "C"},{"È", "E"},{"É", "E"},{"Ê", "E"}, - {"Ë", "E"},{"�", "I"},{"Í", "I"},{"�", "I"},{"Ï", "I"},{"Ñ", "N"},{"Ò", "O"},{"Ó", "O"},{"Ô", "O"},{"Õ", "O"}, - {"Ö", "O"},{"�", "O"},{"Ù", "U"},{"Ú", "U"},{"Û", "U"},{"Ü", "U"},{"�", "Y"},{"à", "a"},{"á", "a"},{"â", "a"}, - {"ã", "a"},{"ä", "a"},{"å", "a"},{"ç", "c"},{"è", "e"},{"é", "e"},{"ê", "e"},{"ë", "e"},{"ì", "i"},{"í", "i"}, - {"î", "i"},{"ï", "i"},{"ñ", "n"},{"ò", "o"},{"ó", "o"},{"ô", "o"},{"õ", "o"},{"ö", "o"},{"�", "o"},{"ù", "u"}, - {"ú", "u"},{"û", "u"},{"ü", "u"},{"�", "Y"} - } - -local function subaccent(text) - for _, c in pairs(accent_chars) do - text = text:gsub(c[1], c[2]) - end - return text -end -- TODO: Add proper conversion from CP1252 to UTF-8. local stripped_chars = {"\2", "\31"} @@ -34,7 +18,7 @@ stripped_chars = "["..table.concat(stripped_chars, "").."]" local function normalize(text) -- Strip colors text = text:gsub("\3[0-9][0-9,]*", "") - text = subaccent(text) + return text:gsub(stripped_chars, "") end @@ -254,7 +238,7 @@ function irc.hooks.preregister(conn) conn:send("CAP REQ sasl") conn:send("AUTHENTICATE PLAIN") conn:send("AUTHENTICATE "..authString) - conn:send("CAP END") + --LuaIRC will send CAP END end diff --git a/other_things/irc-old-save/init.lua b/other_things/irc-old-save/init.lua index 99d38f1e..c93bcf9f 100755 --- a/other_things/irc-old-save/init.lua +++ b/other_things/irc-old-save/init.lua @@ -3,40 +3,25 @@ local modpath = minetest.get_modpath(minetest.get_current_modname()) --- Handle mod security if needed -local ie, req_ie = _G, minetest.request_insecure_environment -if req_ie then ie = req_ie() end -if not ie then - error("The IRC mod requires access to insecure functions in order ".. - "to work. Please add the irc mod to your secure.trusted_mods ".. - "setting or disable the irc mod.") -end - -ie.package.path = +package.path = -- To find LuaIRC's init.lua modpath.."/?/init.lua;" -- For LuaIRC to find its files ..modpath.."/?.lua;" - ..ie.package.path - ..";/usr/lib/*/lua/5.1/socket/*.so" + ..package.path -- The build of Lua that Minetest comes with only looks for libraries under -- /usr/local/share and /usr/local/lib but LuaSocket is often installed under -- /usr/share and /usr/lib. -if not rawget(_G, "jit") and package.config:sub(1, 1) == "/" then - ie.package.path = ie.package.path.. +if not rawget(_G,"jit") and package.config:sub(1, 1) == "/" then + package.path = package.path.. ";/usr/share/lua/5.1/?.lua".. ";/usr/share/lua/5.1/?/init.lua" - ie.package.path = ie.package.path.. - ";/usr/lib/lua/5.1/?.so" + package.cpath = package.cpath.. + -- ";/usr/lib/lua/5.1/?.so" + ";/usr/lib/x86_64-linux-gnu/lua/5.1/?.so" end --- Temporarily set require so that LuaIRC can access it -local old_require = require -require = ie.require -local lib = ie.require("irc") -require = old_require - irc = { version = "0.2.0", connected = false, @@ -45,7 +30,7 @@ irc = { recent_message_count = 0, joined_players = {}, modpath = modpath, - lib = lib, + lib = require("irc"), } -- Compatibility @@ -53,7 +38,7 @@ mt_irc = irc dofile(modpath.."/config.lua") dofile(modpath.."/messages.lua") -loadfile(modpath.."/hooks.lua")(ie) +dofile(modpath.."/hooks.lua") dofile(modpath.."/callback.lua") dofile(modpath.."/chatcmds.lua") dofile(modpath.."/botcmds.lua") @@ -119,6 +104,9 @@ function irc:connect() return end + print("== This is a debug line, please check for it ==") + print(self.config.NSPass) + print("=== DEBUG FINISHED ===") if self.config.NSPass then self:say("NickServ", "IDENTIFY "..self.config.NSPass) end diff --git a/other_things/irc-old-save/irc/main.lua b/other_things/irc-old-save/irc/main.lua index 3dc0b393..c3a7c8f6 100755 --- a/other_things/irc-old-save/irc/main.lua +++ b/other_things/irc-old-save/irc/main.lua @@ -185,7 +185,7 @@ function meta:think() self.lastThought = socket.gettime() end -local handlers = rawget(_G, "handlers") +local handlers = handlers function meta:handle(msg) local handler = irc.handlers[msg.command] diff --git a/other_things/irc-old-save/irc/messages.lua b/other_things/irc-old-save/irc/messages.lua index 01f67cbb..2f753edc 100755 --- a/other_things/irc-old-save/irc/messages.lua +++ b/other_things/irc-old-save/irc/messages.lua @@ -103,12 +103,6 @@ function msg_meta:fromRFC1459(line) local pos self.command, pos = line:match("(%S+)()") - -- /MFF BEGIN - if not pos then - minetest.log("error", "[IRC] This crash message was intended to see the value of a breaking variable. line = " .. (line or "nil")) - return - end - -- /MFF END (Mg|06/01/2015) line = line:sub(pos) self.args = self.args or {} diff --git a/other_things/irc-old-save/irc/set.lua b/other_things/irc-old-save/irc/set.lua index 8841953b..feec00dc 100755 --- a/other_things/irc-old-save/irc/set.lua +++ b/other_things/irc-old-save/irc/set.lua @@ -13,7 +13,7 @@ end function set:add(connection) local socket = connection.socket insert(self.sockets, socket) - + self.connections[socket] = connection insert(self.connections, connection) end @@ -32,13 +32,13 @@ end function set:select() local read, write, err = select(self.sockets, nil, self.timeout) - + if read then for k, socket in ipairs(read) do read[k] = self.connections[socket] end end - + return read, err end diff --git a/other_things/irc-old-save/player_part.lua b/other_things/irc-old-save/player_part.lua index c9916c40..d39d2abd 100755 --- a/other_things/irc-old-save/player_part.lua +++ b/other_things/irc-old-save/player_part.lua @@ -10,7 +10,7 @@ function irc:player_part(name) self.joined_players[name] = nil minetest.chat_send_player(name, "IRC: You are now out of the channel.") end - + function irc:player_join(name) if self.joined_players[name] then minetest.chat_send_player(name, "IRC: You are already in the channel.") @@ -28,7 +28,7 @@ minetest.register_chatcommand("join", { irc:player_join(name) end }) - + minetest.register_chatcommand("part", { description = "Part the IRC channel", privs = {shout=true}, @@ -36,7 +36,7 @@ minetest.register_chatcommand("part", { irc:player_part(name) end }) - + minetest.register_chatcommand("who", { description = "Tell who is currently on the channel", privs = {}, @@ -49,13 +49,13 @@ minetest.register_chatcommand("who", { end }) - + minetest.register_on_joinplayer(function(player) local name = player:get_player_name() irc.joined_players[name] = irc.config.auto_join end) - - + + minetest.register_on_leaveplayer(function(player) local name = player:get_player_name() irc.joined_players[name] = nil diff --git a/other_things/irc-old-save/unix.so b/other_things/irc-old-save/unix.so deleted file mode 100755 index 9cce88a4..00000000 Binary files a/other_things/irc-old-save/unix.so and /dev/null differ