From 10f32b77b0f9353153018127fbec89f74dcb3e9c Mon Sep 17 00:00:00 2001 From: kaeza Date: Fri, 27 Dec 2013 12:57:35 -0200 Subject: [PATCH] Add "[off]" prefix for messages not to be sent to the "other side". If an in-game message begins with "[off]", it's not sent to IRC, and vice-versa. --- README.txt | 3 +++ src/callback.lua | 1 + src/hooks.lua | 2 ++ 3 files changed, 6 insertions(+) diff --git a/README.txt b/README.txt index 9fc2283..081d990 100644 --- a/README.txt +++ b/README.txt @@ -109,6 +109,9 @@ Once the game is connected to the IRC channel, chatting using the 'T' or by anyone. Also, when someone sends a message to the channel, that text will be visible in-game. +Messages that begin with "[off]" from in-game or IRC are not sent to the + other side. + This mod also adds a few chat commands: /irc_msg diff --git a/src/callback.lua b/src/callback.lua index 0104f7a..847f481 100644 --- a/src/callback.lua +++ b/src/callback.lua @@ -21,6 +21,7 @@ end) minetest.register_on_chat_message(function(name, message) if not mt_irc.connected or message:sub(1, 1) == "/" + or message:sub(1, 5) == "[off]" or not mt_irc.joined_players[name] or (not minetest.check_player_privs(name, {shout=true})) then return diff --git a/src/hooks.lua b/src/hooks.lua index d7cf803..baa636e 100644 --- a/src/hooks.lua +++ b/src/hooks.lua @@ -109,6 +109,8 @@ function mt_irc.hooks.channelChat(user, channel, message) if mt_irc:check_botcmd(user, channel, message) then return + elseif message:sub(1, 5) == "[off]" then + return elseif foundchat then mt_irc:sendLocal(("<%s@%s> %s") :format(chatnick, user.nick, chatmessage))