From 4baafeec4682bd8c6eda1ef8f0579c0e62b2913d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Mart=C3=ADnez?= Date: Tue, 8 Jan 2013 14:13:41 -0200 Subject: [PATCH] Fixed player being able to chat on IRC even with no shout privilege --- doc/CHANGES.txt | 1 + src/callback.lua | 8 +++++++- src/config.lua | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/CHANGES.txt b/doc/CHANGES.txt index 5239504..c2a3527 100644 --- a/doc/CHANGES.txt +++ b/doc/CHANGES.txt @@ -11,6 +11,7 @@ Version 0.1.2: - Added automatic reconnection in case the bot is kicked from the channel. - Fixed delay while the bot waits for the Message Of The Day (or topic) + - Added automatic reconnection in case of ping timeout. Version 0.1.1: - Moved all user configuration to `config.lua'. diff --git a/src/callback.lua b/src/callback.lua index fddda5c..e76a21b 100644 --- a/src/callback.lua +++ b/src/callback.lua @@ -113,12 +113,18 @@ minetest.register_on_leaveplayer(function ( player ) end); minetest.register_on_chat_message(function ( name, message ) + if (not mt_irc.connect_ok) then return; end if (message:sub(1, 1) == "/") then return; end if (not mt_irc.connected_players[name]) then --minetest.chat_send_player(name, "IRC: You are not connected. Please use /join"); return; end - if (not mt_irc.connect_ok) then return; end + local privs = minetest.get_player_privs(name); + if (not privs.shout) then + minetest.chat_send_player(name, "IRC: No shout priv"); + irc.say(mt_irc.channel, "DEBUG: message from unpriviledged player: "..name); + return; + end if (not mt_irc.buffered_messages) then mt_irc.buffered_messages = { }; end diff --git a/src/config.lua b/src/config.lua index 507d90c..5d09447 100644 --- a/src/config.lua +++ b/src/config.lua @@ -36,7 +36,7 @@ mt_irc.timeout = nil; -- Nickname when using single conection (string, default "minetest-"..); -- ( is the server IP address packed as a 32 bit integer). -mt_irc.server_nick = "HelloIRC"; +mt_irc.server_nick = nil; -- Password to use when using single connection (string, default "") mt_irc.password = nil;