From c9c57a6f93c5edcacda7013bd9369499df6b2db4 Mon Sep 17 00:00:00 2001 From: D Tim Cummings Date: Tue, 19 Jun 2018 05:45:44 +1000 Subject: [PATCH 01/10] Avoid deprecation warnings. * This change avoids 21 deprecation warnings in debug.txt on every server start 2018-05-29 23:46:10: WARNING[Main]: WARNING: minetest.setting_* functions are deprecated. Use methods on the minetest.settings object. * Provide backward compatibility by testing for existence of new methods before using them --- config.lua | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/config.lua b/config.lua index c629e47..10e5eb1 100644 --- a/config.lua +++ b/config.lua @@ -6,12 +6,24 @@ irc.config = {} local function setting(stype, name, default, required) local value - 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)) + 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 + value = minetest.settings:get("irc."..name) + 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 From b4fbccd64ac758ee698f4f741250e9b682903363 Mon Sep 17 00:00:00 2001 From: Anand S Date: Sun, 9 Sep 2018 21:38:02 +0530 Subject: [PATCH 02/10] Add support for configurable coloring of IRC messages in-game IRC channel messages are colored green by default IRC PMs are colored purple by default --- botcmds.lua | 3 ++- config.lua | 5 +++-- messages.lua | 2 +- player_part.lua | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/botcmds.lua b/botcmds.lua index ba0d025..ec888ea 100644 --- a/botcmds.lua +++ b/botcmds.lua @@ -51,7 +51,8 @@ function irc.bot_command(msg, text) return end minetest.chat_send_player(player_to, - "PM from "..msg.user.nick.."@IRC: "..message, false) + minetest.colorize(irc.config.pm_color, + "PM from "..msg.user.nick.."@IRC: "..message, false)) irc.reply("Message sent!") return end diff --git a/config.lua b/config.lua index 10e5eb1..9a5c1fc 100644 --- a/config.lua +++ b/config.lua @@ -23,7 +23,7 @@ local function setting(stype, name, default, required) value = minetest.setting_get("irc."..name) elseif stype == "number" then value = tonumber(minetest.setting_get("irc."..name)) - end + end end if value == nil then if required then @@ -65,4 +65,5 @@ setting("bool", "debug", false) -- Enable debug output setting("bool", "enable_player_part", true) -- Whether to enable players joining and parting the channel setting("bool", "auto_join", true) -- Whether to automatically show players in the channel when they join setting("bool", "auto_connect", true) -- Whether to automatically connect to the server on mod load - +setting("string", "chat_color", "#339933") -- Color of IRC chat in-game, green by default +setting("string", "pm_color", "#8800AA") -- Color of IRC PMs in-game, purple by default diff --git a/messages.lua b/messages.lua index 83e4f7f..52b1d4c 100644 --- a/messages.lua +++ b/messages.lua @@ -8,7 +8,7 @@ function irc.logChat(message) end function irc.sendLocal(message) - minetest.chat_send_all(message) + minetest.chat_send_all(minetest.colorize(irc.config.chat_color, message)) irc.logChat(message) end diff --git a/player_part.lua b/player_part.lua index e703316..09aad75 100644 --- a/player_part.lua +++ b/player_part.lua @@ -63,7 +63,8 @@ end) function irc.sendLocal(message) for name, _ in pairs(irc.joined_players) do - minetest.chat_send_player(name, message) + minetest.chat_send_player(name, + minetest.colorize(irc.config.chat_color, message)) end irc.logChat(message) end From 66bb7fc47d61f06fea098ca9dfa1981820dd29be Mon Sep 17 00:00:00 2001 From: luk3yx Date: Tue, 12 Feb 2019 17:10:41 +1300 Subject: [PATCH 03/10] Prevent players from joining the channel when logged in from IRC --- player_part.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/player_part.lua b/player_part.lua index 09aad75..0e7b1c6 100644 --- a/player_part.lua +++ b/player_part.lua @@ -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" From 1c23f8987bd6b3f5f1e2d9023128972a93088b8b Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Wed, 13 Feb 2019 21:46:50 -0500 Subject: [PATCH 04/10] add another lua search path for JIT --- init.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/init.lua b/init.lua index 67dec28..62d8fdd 100644 --- a/init.lua +++ b/init.lua @@ -23,11 +23,17 @@ 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" + + 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 From 05ab5e9fbd20276da802b047209149f97d606da9 Mon Sep 17 00:00:00 2001 From: rdococ Date: Sat, 21 Sep 2019 14:22:41 +0100 Subject: [PATCH 05/10] Fix message when a player on another server times out (#58) --- hooks.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hooks.lua b/hooks.lua index 0ac3597..19a85ae 100644 --- a/hooks.lua +++ b/hooks.lua @@ -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)) From ac0387786cc9f9e5b44a072e88289041182b6628 Mon Sep 17 00:00:00 2001 From: David Leal Date: Sat, 5 Oct 2019 02:25:05 -0500 Subject: [PATCH 06/10] Fix deprecated functions, update to 5.x (#59) --- botcmds.lua | 2 +- config.lua | 10 ---------- description.txt | 4 ---- init.lua | 3 ++- mod.conf | 4 ++++ 5 files changed, 7 insertions(+), 16 deletions(-) delete mode 100644 description.txt diff --git a/botcmds.lua b/botcmds.lua index ec888ea..5d78917 100644 --- a/botcmds.lua +++ b/botcmds.lua @@ -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 }) diff --git a/config.lua b/config.lua index 9a5c1fc..2f72066 100644 --- a/config.lua +++ b/config.lua @@ -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 diff --git a/description.txt b/description.txt deleted file mode 100644 index 58ba37a..0000000 --- a/description.txt +++ /dev/null @@ -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. diff --git a/init.lua b/init.lua index 62d8fdd..2dfaa7d 100644 --- a/init.lua +++ b/init.lua @@ -110,7 +110,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 diff --git a/mod.conf b/mod.conf index ba3caea..986c319 100644 --- a/mod.conf +++ b/mod.conf @@ -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. +""" From 5e3659761b02b5f9c34f40854eafcc27fef1c93a Mon Sep 17 00:00:00 2001 From: Wade Cline Date: Thu, 17 Oct 2019 12:29:02 -0700 Subject: [PATCH 07/10] Add extra library search path (#60) --- init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 2dfaa7d..06e71c3 100644 --- a/init.lua +++ b/init.lua @@ -29,7 +29,8 @@ if not rawget(_G, "jit") and package.config:sub(1, 1) == "/" then ";/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 From ceb40e2bb305b19044fd97375f609f70f8ae4ac5 Mon Sep 17 00:00:00 2001 From: David Leal Date: Wed, 19 Feb 2020 11:46:29 -0600 Subject: [PATCH 08/10] Add luacheck GitHub integration (#62) --- .github/workflows/check-release.yml | 11 +++++++++++ .luacheckrc | 2 +- README.md | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/check-release.yml diff --git a/.github/workflows/check-release.yml b/.github/workflows/check-release.yml new file mode 100644 index 0000000..0bf4842 --- /dev/null +++ b/.github/workflows/check-release.yml @@ -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 diff --git a/.luacheckrc b/.luacheckrc index 7453628..326c56a 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -2,7 +2,7 @@ allow_defined_top = true read_globals = { - "minetest", + "minetest" } exclude_files = { diff --git a/README.md b/README.md index 99e0dcc..5aa1f76 100644 --- a/README.md +++ b/README.md @@ -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 ==================== From cc78f12a4c604f64d111d47012316aa05577fecd Mon Sep 17 00:00:00 2001 From: Andrey Kozlovskiy Date: Sat, 18 Jul 2020 18:57:42 +0300 Subject: [PATCH 09/10] Display total number of players with /who (#65) --- player_part.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/player_part.lua b/player_part.lua index 0e7b1c6..3a22292 100644 --- a/player_part.lua +++ b/player_part.lua @@ -47,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 }) From 7fbbfd6cdbb239a059e42fdaf101b760346d06b9 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Sat, 18 Jul 2020 18:00:38 +0200 Subject: [PATCH 10/10] Fix failing luacheck --- callback.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/callback.lua b/callback.lua index 29667ba..89a6a90 100644 --- a/callback.lua +++ b/callback.lua @@ -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)