mirror of
https://github.com/minetest-mods/irc.git
synced 2024-12-26 17:00:17 +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
|
||||
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 <message> 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
|
||||
|
@ -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, ...)
|
||||
|
4
init.lua
4
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()
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user