From 30fa81a3abdabd3382b497b53d7f0c923a058c3f Mon Sep 17 00:00:00 2001
From: ShadowNinja <shadowninja@minetest.net>
Date: Tue, 27 Jan 2015 11:36:29 -0500
Subject: [PATCH] Don't allow a user with the nick "IRC" to impersonate other
 users

---
 hooks.lua | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/hooks.lua b/hooks.lua
index 975c89c..6c8e243 100644
--- a/hooks.lua
+++ b/hooks.lua
@@ -104,6 +104,14 @@ end
 function irc.hooks.channelChat(msg)
 	local text = normalize(msg.args[2])
 
+	irc:check_botcmd(msg)
+
+	-- Don't let a user impersonate someone else by using the nick "IRC"
+	if msg.user.nick == "IRC" then
+		irc:sendLocal("<IRC@IRC> "..text)
+		return
+	end
+
 	-- Support multiple servers in a channel better by converting:
 	-- "<server@IRC> <player> message" into "<player@server> message"
 	-- "<server@IRC> *** player joined/left the game" into "*** player joined/left server"
@@ -117,8 +125,6 @@ function irc.hooks.channelChat(msg)
 	local foundaction, _, actionnick, actionmessage =
 		text:find("^%* ([^%s]+) (.*)$")
 
-	irc:check_botcmd(msg)
-
 	if text:sub(1, 5) == "[off]" then
 		return
 	elseif foundchat then
-- 
GitLab