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 ==================== diff --git a/botcmds.lua b/botcmds.lua index ba0d025..5d78917 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 @@ -138,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/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) diff --git a/config.lua b/config.lua index c629e47..2f72066 100644 --- a/config.lua +++ b/config.lua @@ -6,12 +6,14 @@ 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 + 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 end if value == nil then if required then @@ -53,4 +55,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/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/hooks.lua b/hooks.lua index d80bf8d..5b3d461 100644 --- a/hooks.lua +++ b/hooks.lua @@ -122,6 +122,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]+) (.*)$") @@ -136,6 +138,9 @@ function irc.hooks.channelChat(msg) elseif foundleave then irc.sendLocal((core.colorize("#c44e4e", "⬅ ")..core.colorize(failure, " %s")..core.colorize(important," just 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"..core.colorize("#A3B5CB","@%s").." %s") :format(actionnick, msg.user.nick, actionmessage)) diff --git a/init.lua b/init.lua index 67dec28..06e71c3 100644 --- a/init.lua +++ b/init.lua @@ -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 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/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. +""" diff --git a/player_part.lua b/player_part.lua index e703316..3a22292 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" @@ -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 }) @@ -63,7 +65,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