mirror of
https://github.com/minetest-mods/irc.git
synced 2024-12-27 17:20:20 +01:00
Add .luacheckrc
and fix warnings.
This commit is contained in:
parent
6bbb26f9f9
commit
33542b07fe
14
.luacheckrc
Normal file
14
.luacheckrc
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
unused_args = false
|
||||||
|
allow_defined_top = true
|
||||||
|
|
||||||
|
read_globals = {
|
||||||
|
"minetest",
|
||||||
|
}
|
||||||
|
|
||||||
|
exclude_files = {
|
||||||
|
"irc/*",
|
||||||
|
}
|
||||||
|
|
||||||
|
globals = {
|
||||||
|
}
|
@ -40,7 +40,7 @@ function irc:bot_command(msg, text)
|
|||||||
-- Remove leading whitespace
|
-- Remove leading whitespace
|
||||||
text = text:match("^%s*(.*)")
|
text = text:match("^%s*(.*)")
|
||||||
if text:sub(1, 1) == "@" then
|
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
|
if not minetest.get_player_by_name(player_to) then
|
||||||
irc:reply("User '"..player_to.."' is not in the game.")
|
irc:reply("User '"..player_to.."' is not in the game.")
|
||||||
return
|
return
|
||||||
@ -69,7 +69,7 @@ function irc:bot_command(msg, text)
|
|||||||
return
|
return
|
||||||
end
|
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
|
if message then
|
||||||
self:reply(message)
|
self:reply(message)
|
||||||
end
|
end
|
||||||
|
@ -76,8 +76,8 @@ minetest.register_chatcommand("irc_disconnect", {
|
|||||||
if not irc.connected then
|
if not irc.connected then
|
||||||
return false, "Not connected to IRC. Use /irc_connect to connect."
|
return false, "Not connected to IRC. Use /irc_connect to connect."
|
||||||
end
|
end
|
||||||
if params == "" then
|
if param == "" then
|
||||||
params = "Manual disconnect by "..name
|
param = "Manual disconnect by "..name
|
||||||
end
|
end
|
||||||
irc:disconnect(param)
|
irc:disconnect(param)
|
||||||
end
|
end
|
||||||
@ -113,6 +113,7 @@ minetest.register_chatcommand("irc_quote", {
|
|||||||
|
|
||||||
|
|
||||||
local oldme = minetest.chatcommands["me"].func
|
local oldme = minetest.chatcommands["me"].func
|
||||||
|
-- luacheck: ignore
|
||||||
minetest.chatcommands["me"].func = function(name, param, ...)
|
minetest.chatcommands["me"].func = function(name, param, ...)
|
||||||
irc:say(("* %s %s"):format(name, param))
|
irc:say(("* %s %s"):format(name, param))
|
||||||
return oldme(name, param, ...)
|
return oldme(name, param, ...)
|
||||||
|
4
init.lua
4
init.lua
@ -52,7 +52,7 @@ irc = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- Compatibility
|
-- Compatibility
|
||||||
mt_irc = irc
|
rawset(_G, "mt_irc", irc)
|
||||||
|
|
||||||
dofile(modpath.."/config.lua")
|
dofile(modpath.."/config.lua")
|
||||||
dofile(modpath.."/messages.lua")
|
dofile(modpath.."/messages.lua")
|
||||||
@ -113,7 +113,7 @@ function irc:connect()
|
|||||||
|
|
||||||
-- We need to swap the `require` function again since
|
-- We need to swap the `require` function again since
|
||||||
-- LuaIRC `require`s `ssl` if `irc.secure` is true.
|
-- LuaIRC `require`s `ssl` if `irc.secure` is true.
|
||||||
local old_require = require
|
old_require = require
|
||||||
require = ie.require
|
require = ie.require
|
||||||
|
|
||||||
local good, message = pcall(function()
|
local good, message = pcall(function()
|
||||||
|
@ -40,9 +40,9 @@ minetest.register_chatcommand("who", {
|
|||||||
privs = {},
|
privs = {},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local out, n = { }, 0
|
local out, n = { }, 0
|
||||||
for name in pairs(irc.joined_players) do
|
for plname in pairs(irc.joined_players) do
|
||||||
n = n + 1
|
n = n + 1
|
||||||
out[n] = name
|
out[n] = plname
|
||||||
end
|
end
|
||||||
table.sort(out)
|
table.sort(out)
|
||||||
return true, "Players in channel: "..table.concat(out, ", ")
|
return true, "Players in channel: "..table.concat(out, ", ")
|
||||||
|
Loading…
Reference in New Issue
Block a user