From 873fab6d3621be2acd0157e341f79413183d040c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Mart=C3=ADnez?= Date: Mon, 31 Dec 2012 13:53:01 -0200 Subject: [PATCH] Added /irc_disconnect and /irc_reconnect --- README.txt | 13 ++++++++++--- src/chatcmds.lua | 29 +++++++++++++++++++++++++++++ src/init.lua | 2 ++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/README.txt b/README.txt index 0c513c9..0250551 100644 --- a/README.txt +++ b/README.txt @@ -118,9 +118,16 @@ All settings are changed in the `config.lua' file. If any of these settings mt_irc.debug (boolean, default false) Whether to output debug information. - mt_irc.connect_on_join (boolean, default false) - If true, players are connected by default. If false, players - have to use the /irc_connect command to connect to the server. + mt_irc.auto_connect (boolean, default false) + If true, the bot is connected by default. If false, a player with + `irc_admin' privilege has to use the /irc_connect command to + connect to the server. + + mt_irc.auto_connect (boolean, default false) + If true, players join the channel automatically upon entering the + game. If false, each user must manually use the /join command to + join the channel. In any case, the players may use the /part + command to opt-out of being in the channel. USAGE ----- diff --git a/src/chatcmds.lua b/src/chatcmds.lua index b4db8e3..c46f72b 100644 --- a/src/chatcmds.lua +++ b/src/chatcmds.lua @@ -36,6 +36,35 @@ minetest.register_chatcommand("irc_connect", { end; }); +minetest.register_chatcommand("irc_disconnect", { + params = ""; + description = "Disconnect from the IRC server"; + privs = { irc_admin=true; }; + func = function ( name, param ) + if (not mt_irc.connect_ok) then + minetest.chat_send_player(name, "IRC: You are not connected."); + return; + end + irc.quit("Manual BOT Disconnection"); + minetest.chat_send_player(name, "IRC: You are now disconnected."); + mt_irc.connect_ok = false; + end; +}); + +minetest.register_chatcommand("irc_reconnect", { + params = ""; + description = "Reconnect to the IRC server"; + privs = { irc_admin=true; }; + func = function ( name, param ) + if (mt_irc.connect_ok) then + irc.quit("Reconnecting BOT..."); + minetest.chat_send_player(name, "IRC: Reconnecting bot..."); + mt_irc.connect_ok = false; + end + mt_irc.connect(); + end; +}); + minetest.register_chatcommand("join", { params = ""; description = "Join the IRC channel"; diff --git a/src/init.lua b/src/init.lua index acd8083..baa1e3b 100644 --- a/src/init.lua +++ b/src/init.lua @@ -133,6 +133,8 @@ mt_irc.say = function ( to, msg ) irc.say(to, msg); end +mt_irc._irc = irc; + dofile(MODPATH.."/callback.lua"); dofile(MODPATH.."/chatcmds.lua"); dofile(MODPATH.."/botcmds.lua");