diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..3818bc3 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,14 @@ + +unused_args = false +allow_defined_top = true + +read_globals = { + "minetest", +} + +exclude_files = { + "irc/*", +} + +globals = { +} diff --git a/botcmds.lua b/botcmds.lua index a6d72ca..4109cf0 100644 --- a/botcmds.lua +++ b/botcmds.lua @@ -40,7 +40,7 @@ function irc:bot_command(msg, text) -- Remove leading whitespace text = text:match("^%s*(.*)") if text:sub(1, 1) == "@" then - local found, _, player_to, message = text:find("^.([^%s]+)%s(.+)$") + local _, _, player_to, message = text:find("^.([^%s]+)%s(.+)$") if not minetest.get_player_by_name(player_to) then irc:reply("User '"..player_to.."' is not in the game.") return @@ -62,14 +62,14 @@ 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) + + local _, message = self.bot_commands[cmd].func(msg.user, args) if message then self:reply(message) end diff --git a/chatcmds.lua b/chatcmds.lua index 5edf04c..b0a0048 100644 --- a/chatcmds.lua +++ b/chatcmds.lua @@ -76,8 +76,8 @@ minetest.register_chatcommand("irc_disconnect", { if not irc.connected then return false, "Not connected to IRC. Use /irc_connect to connect." end - if params == "" then - params = "Manual disconnect by "..name + if param == "" then + param = "Manual disconnect by "..name end irc:disconnect(param) end @@ -113,6 +113,7 @@ minetest.register_chatcommand("irc_quote", { local oldme = minetest.chatcommands["me"].func +-- luacheck: ignore minetest.chatcommands["me"].func = function(name, param, ...) irc:say(("* %s %s"):format(name, param)) return oldme(name, param, ...) diff --git a/init.lua b/init.lua index 628f809..18e4fbe 100644 --- a/init.lua +++ b/init.lua @@ -52,7 +52,7 @@ irc = { } -- Compatibility -mt_irc = irc +rawset(_G, "mt_irc", irc) dofile(modpath.."/config.lua") dofile(modpath.."/messages.lua") @@ -113,7 +113,7 @@ function irc:connect() -- We need to swap the `require` function again since -- LuaIRC `require`s `ssl` if `irc.secure` is true. - local old_require = require + old_require = require require = ie.require local good, message = pcall(function() diff --git a/player_part.lua b/player_part.lua index d539d3b..7fd7e37 100644 --- a/player_part.lua +++ b/player_part.lua @@ -9,7 +9,7 @@ function irc:player_part(name) self.joined_players[name] = nil return true, "You left the channel" end - + function irc:player_join(name) if self.joined_players[name] then return false, "You are already in the channel" @@ -26,7 +26,7 @@ minetest.register_chatcommand("join", { return irc:player_join(name) end }) - + minetest.register_chatcommand("part", { description = "Part the IRC channel", privs = {shout=true}, @@ -34,28 +34,28 @@ minetest.register_chatcommand("part", { return irc:player_part(name) end }) - + minetest.register_chatcommand("who", { description = "Tell who is currently on the channel", privs = {}, func = function(name, param) local out, n = { }, 0 - for name in pairs(irc.joined_players) do + for plname in pairs(irc.joined_players) do n = n + 1 - out[n] = name + out[n] = plname end table.sort(out) return true, "Players in channel: "..table.concat(out, ", ") 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