mirror of
https://github.com/minetest-mods/irc.git
synced 2024-12-27 01:10: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
|
-- 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
|
||||||
@ -62,14 +62,14 @@ function irc:bot_command(msg, text)
|
|||||||
cmd = text
|
cmd = text
|
||||||
args = ""
|
args = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
if not self.bot_commands[cmd] then
|
if not self.bot_commands[cmd] then
|
||||||
self:reply("Unknown command '"..cmd.."'. Try 'list'."
|
self:reply("Unknown command '"..cmd.."'. Try 'list'."
|
||||||
.." Or use @playername <message> to send a private message")
|
.." Or use @playername <message> to send a private message")
|
||||||
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()
|
||||||
|
@ -9,7 +9,7 @@ function irc:player_part(name)
|
|||||||
self.joined_players[name] = nil
|
self.joined_players[name] = nil
|
||||||
return true, "You left the channel"
|
return true, "You left the channel"
|
||||||
end
|
end
|
||||||
|
|
||||||
function irc:player_join(name)
|
function irc:player_join(name)
|
||||||
if self.joined_players[name] then
|
if self.joined_players[name] then
|
||||||
return false, "You are already in the channel"
|
return false, "You are already in the channel"
|
||||||
@ -26,7 +26,7 @@ minetest.register_chatcommand("join", {
|
|||||||
return irc:player_join(name)
|
return irc:player_join(name)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_chatcommand("part", {
|
minetest.register_chatcommand("part", {
|
||||||
description = "Part the IRC channel",
|
description = "Part the IRC channel",
|
||||||
privs = {shout=true},
|
privs = {shout=true},
|
||||||
@ -34,28 +34,28 @@ minetest.register_chatcommand("part", {
|
|||||||
return irc:player_part(name)
|
return irc:player_part(name)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_chatcommand("who", {
|
minetest.register_chatcommand("who", {
|
||||||
description = "Tell who is currently on the channel",
|
description = "Tell who is currently on the channel",
|
||||||
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, ", ")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
irc.joined_players[name] = irc.config.auto_join
|
irc.joined_players[name] = irc.config.auto_join
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
irc.joined_players[name] = nil
|
irc.joined_players[name] = nil
|
||||||
|
Loading…
Reference in New Issue
Block a user