From 04a76fc0c734730a49e3a0f965b550136ce040a7 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Wed, 7 Aug 2019 22:01:47 -0700 Subject: [PATCH] Unsure if I want to keep this, but, IRC server admin announcements. --- mods/announce/init.lua | 24 ++++++++++++++++++++++++ mods/telex/init.lua | 3 +++ readme.md | 2 ++ 3 files changed, 29 insertions(+) diff --git a/mods/announce/init.lua b/mods/announce/init.lua index 21bf9bb..143ab6b 100644 --- a/mods/announce/init.lua +++ b/mods/announce/init.lua @@ -29,3 +29,27 @@ function announce.all(msg) end end +function announce.player(name, msg) + minetest.log("action", "announce to " .. name .. ": " .. msg) + minetest.chat_send_player(name, msg) + if irc and irc.joined_players[name] then + irc.whisper(name, msg) + end +end + +function announce.admins(msg) + minetest.log("action", "admin announce: " .. msg) + if not irc then + return + end + local irclist = minetest.settings:get("announce_irc_admins") + if irclist == "" then + return + end + local admins = string.split(string.gsub(irclist, " ", ""), ",") + for _, name in pairs(admins) do + if irc.joined_players[name] then + irc.whisper(name, msg) + end + end +end diff --git a/mods/telex/init.lua b/mods/telex/init.lua index b63a82f..249b83d 100644 --- a/mods/telex/init.lua +++ b/mods/telex/init.lua @@ -160,6 +160,7 @@ function telex.deliver(message) table.insert(spool, message) S:set_string("telex_spool", telex.encode(spool)) minetest.log("action", "spooled a message from <" .. message.from .. "> to <" .. message.to .. ">") + announce.admins("spooled a message from <" .. message.from .. "> to <" .. message.to .. ">") end end @@ -168,6 +169,7 @@ function telex.retour(message) if message.from == "MAILER-DEAMON" then -- discard, we tried hard enough! minetest.log("action", "discarded an expired spool message from <" .. message.from .. "> to <" .. message.to .. ">") + announce.admins("discarded an expired spool message from <" .. message.from .. "> to <" .. message.to .. ">") return end @@ -181,6 +183,7 @@ function telex.retour(message) table.insert(message.content, 2, "================== ORIGINAL MESSAGE BELOW ================") telex.deliver(message) minetest.log("action", "returned a message from <" .. from .. "> back to <" .. to .. ">") + announce.admins("returned a message from <" .. from .. "> back to <" .. to .. ">") end -- returns message/mbox diff --git a/readme.md b/readme.md index 172a34d..5e906b3 100644 --- a/readme.md +++ b/readme.md @@ -249,4 +249,6 @@ tutorial_entry_lobby = -- tutorial entry lobby box_id tutorial_exit_lobby = -- tutorial exit lobby box_id tutorial_exit = (,,) -- where to teleport player at end of tutorial +announce_irc_admins = "john,frank" -- no spaces, lists irc names that will receive admin announcements + ```