1
0
mirror of https://github.com/minetest-mods/irc.git synced 2024-12-27 17:20:20 +01:00

Added auto-reconnection if bot is kicked

This commit is contained in:
Diego Martínez 2013-01-06 07:15:16 -02:00
parent 46c1bac9a5
commit 8c826f2639
2 changed files with 15 additions and 0 deletions

View File

@ -79,6 +79,17 @@ irc.register_callback("private_msg", function ( from, message )
minetest.chat_send_player(player_to, "PRIVATE: "..text);
end);
irc.register_callback("kick", function ( chaninfo, to, from )
if (mt_irc.connect_ok) then
mt_irc.connect_ok = false;
minetest.chat_send_all("IRC: Bot was kicked by "..from..". Reconnecting bot in 5 seconds...");
mt_irc.got_motd = true;
mt_irc.connect_ok = false;
irc.quit("Kicked");
minetest.after(5, mt_irc.connect);
end
end);
irc.register_callback("nick_change", function ( from, old_nick )
if (not mt_irc.connect_ok) then return; end
end);
@ -108,4 +119,7 @@ end);
minetest.register_on_shutdown(function ( )
irc.quit("Game shutting down.");
for n = 1, 5 do
irc.poll();
end
end);

View File

@ -59,6 +59,7 @@ minetest.register_chatcommand("irc_reconnect", {
if (mt_irc.connect_ok) then
irc.quit("Reconnecting BOT...");
minetest.chat_send_player(name, "IRC: Reconnecting bot...");
mt_irc.got_motd = true;
mt_irc.connect_ok = false;
end
mt_irc.connect();