Compare commits

..

10 Commits

Author SHA1 Message Date
s20
c088ba4e40
Add number of connected players to players command (#73)
Some checks failed
Check & Release / lint (push) Has been cancelled
2023-11-04 18:56:07 +01:00
Miniontoby
758e9b6361
Fix error caused by ident check notice (#71)
Fixed the error where it cannot find an user at the notice hook. 
It happened when you get the `NOTICE * :*** Looking up your hostname and checking ident`
Because `*` is not in the `<nick>!<ident>@<host>`
2022-03-23 22:13:51 +01:00
SmallJoker
7fbbfd6cdb Fix failing luacheck 2020-07-18 18:00:38 +02:00
Andrey Kozlovskiy
cc78f12a4c
Display total number of players with /who (#65) 2020-07-18 17:57:42 +02:00
David Leal
ceb40e2bb3
Add luacheck GitHub integration (#62) 2020-02-19 18:46:29 +01:00
Wade Cline
5e3659761b Add extra library search path (#60) 2019-10-17 21:29:02 +02:00
David Leal
ac0387786c Fix deprecated functions, update to 5.x (#59) 2019-10-05 09:25:05 +02:00
rdococ
05ab5e9fbd Fix message when a player on another server times out (#58) 2019-09-21 15:22:41 +02:00
Vanessa Dannenberg
1c23f8987b add another lua search path for JIT 2019-02-15 20:32:28 -03:00
luk3yx
66bb7fc47d Prevent players from joining the channel when logged in from IRC 2019-02-12 19:17:09 -03:00
11 changed files with 42 additions and 23 deletions

11
.github/workflows/check-release.yml vendored Normal file
View File

@ -0,0 +1,11 @@
on: [push, pull_request]
name: Check & Release
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: lint
uses: Roang-zero1/factorio-mod-luacheck@master
with:
luacheckrc_url: https://raw.githubusercontent.com/minetest-mods/irc/master/.luacheckrc

View File

@ -2,7 +2,7 @@
allow_defined_top = true
read_globals = {
"minetest",
"minetest"
}
exclude_files = {

View File

@ -1,3 +1,4 @@
[![](https://github.com/minetest-mods/irc/workflows/Check%20&%20Release/badge.svg)](https://github.com/minetest-mods/irc/actions)
IRC Mod for Minetest
====================

View File

@ -139,7 +139,7 @@ irc.register_bot_command("whereis", {
return false, "There is no player named '"..args.."'"
end
local fmt = "Player %s is at (%.2f,%.2f,%.2f)"
local pos = player:getpos()
local pos = player:get_pos()
return true, fmt:format(args, pos.x, pos.y, pos.z)
end
})
@ -169,8 +169,10 @@ irc.register_bot_command("players", {
for _, player in pairs(players) do
table.insert(names, player:get_player_name())
end
return true, "Connected players: "
..table.concat(names, ", ")
return true, string.format("%d connected player(s): %s",
#players,
table.concat(names, ", ")
)
end
})

View File

@ -31,7 +31,7 @@ minetest.register_on_chat_message(function(name, message)
if nl then
message = message:sub(1, nl - 1)
end
irc.say(irc.playerMessage(name, core.strip_colors(message)))
irc.say(irc.playerMessage(name, minetest.strip_colors(message)))
end)

View File

@ -7,7 +7,6 @@ irc.config = {}
local function setting(stype, name, default, required)
local value
if minetest.settings and minetest.settings.get and minetest.settings.get_bool then
-- The current methods for getting settings
if stype == "bool" then
value = minetest.settings:get_bool("irc."..name)
elseif stype == "string" then
@ -15,15 +14,6 @@ local function setting(stype, name, default, required)
elseif stype == "number" then
value = tonumber(minetest.settings:get("irc."..name))
end
else
-- The old methods for getting settings for backward compatibility. Deprecated on 0.4.16+
if stype == "bool" then
value = minetest.setting_getbool("irc."..name)
elseif stype == "string" then
value = minetest.setting_get("irc."..name)
elseif stype == "number" then
value = tonumber(minetest.setting_get("irc."..name))
end
end
if value == nil then
if required then

View File

@ -1,4 +0,0 @@
This mod is just a glue between IRC and Minetest.
It provides two-way communication between the
in-game chat, and an arbitrary IRC channel.

View File

@ -120,6 +120,8 @@ function irc.hooks.channelChat(msg)
text:find("^%*%*%* ([^%s]+) joined the game$")
local foundleave, _, leavenick =
text:find("^%*%*%* ([^%s]+) left the game$")
local foundtimedout, _, timedoutnick =
text:find("^%*%*%* ([^%s]+) left the game %(Timed out%)$")
local foundaction, _, actionnick, actionmessage =
text:find("^%* ([^%s]+) (.*)$")
@ -134,6 +136,9 @@ function irc.hooks.channelChat(msg)
elseif foundleave then
irc.sendLocal(("*** %s left %s")
:format(leavenick, msg.user.nick))
elseif foundtimedout then
irc.sendLocal(("*** %s left %s (Timed out)")
:format(timedoutnick, msg.user.nick))
elseif foundaction then
irc.sendLocal(("* %s@%s %s")
:format(actionnick, msg.user.nick, actionmessage))
@ -166,7 +171,7 @@ end
function irc.hooks.notice(user, target, message)
if user.nick and target == irc.config.channel then
if user and user.nick and target == irc.config.channel then
irc.sendLocal("-"..user.nick.."@IRC- "..message)
end
end

View File

@ -23,11 +23,18 @@ ie.package.path =
-- /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..
";/usr/share/lua/5.1/?.lua"..
";/usr/share/lua/5.1/?/init.lua"
ie.package.cpath = ie.package.cpath..
";/usr/lib/lua/5.1/?.so"
";/usr/lib/lua/5.1/?.so"..
";/usr/lib64/lua/5.1/?.so"
ie.package.cpath = "/usr/lib/x86_64-linux-gnu/lua/5.1/?.so;"..ie.package.cpath
end
-- Temporarily set require so that LuaIRC can access it
@ -104,7 +111,8 @@ end
minetest.register_privilege("irc_admin", {
description = "Allow IRC administrative tasks to be performed.",
give_to_singleplayer = true
give_to_singleplayer = true,
give_to_admin = true,
})
local stepnum = 0

View File

@ -1 +1,5 @@
name = irc
description = """
This mod is just a glue between IRC and Minetest.
It provides two-way communication between the in-game chat, and an arbitrary IRC channel.
"""

View File

@ -13,6 +13,8 @@ end
function irc.player_join(name)
if irc.joined_players[name] then
return false, "You are already in the channel"
elseif not minetest.get_player_by_name(name) then
return false, "You need to be in-game to join the channel"
end
irc.joined_players[name] = true
return true, "You joined the channel"
@ -45,7 +47,7 @@ minetest.register_chatcommand("who", {
out[n] = plname
end
table.sort(out)
return true, "Players in channel: "..table.concat(out, ", ")
return true, n.." player(s) in channel: "..table.concat(out, ", ")
end
})