forked from minetest-mods/irc
Added auto-reconnect on ping timeout
This commit is contained in:
parent
10afaf5783
commit
7caf0dc25f
@ -183,8 +183,6 @@ I'd like to thank the users who supported this mod both on the Minetest
|
|||||||
|
|
||||||
LICENSE
|
LICENSE
|
||||||
-------
|
-------
|
||||||
This license applies only to the `init.lua' and `config.lua' files.
|
|
||||||
|
|
||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
Version 2, December 2004
|
Version 2, December 2004
|
||||||
|
|
||||||
|
2
etc/quickinst.sh
Executable file
2
etc/quickinst.sh
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
(cd Build && cmake . && make && make pack_mod && rm -fr ~/.minetest/games/testing/mods/irc && cp -fr irc ~/.minetest/games/testing/mods/ )
|
@ -1,7 +1,21 @@
|
|||||||
|
|
||||||
|
-- IRC Mod for Minetest
|
||||||
|
-- By Diego Martínez <kaeza@users.sf.net>
|
||||||
|
--
|
||||||
|
-- This mod allows to tie a Minetest server to an IRC channel.
|
||||||
|
--
|
||||||
|
-- This program is free software. It comes without any warranty, to
|
||||||
|
-- the extent permitted by applicable law. You can redistribute it
|
||||||
|
-- and/or modify it under the terms of the Do What The Fuck You Want
|
||||||
|
-- To Public License, Version 2, as published by Sam Hocevar. See
|
||||||
|
-- http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||||
|
--
|
||||||
|
|
||||||
|
local irc = require("irc");
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function ( player )
|
minetest.register_on_joinplayer(function ( player )
|
||||||
|
|
||||||
irc.say(mt_irc.channel, "*** "..player:get_player_name().." joined the game");
|
mt_irc.say(mt_irc.channel, "*** "..player:get_player_name().." joined the game");
|
||||||
mt_irc.connected_players[player:get_player_name()] = mt_irc.auto_join;
|
mt_irc.connected_players[player:get_player_name()] = mt_irc.auto_join;
|
||||||
|
|
||||||
end);
|
end);
|
||||||
@ -39,7 +53,7 @@ local function bot_command ( from, message )
|
|||||||
end
|
end
|
||||||
|
|
||||||
if (not mt_irc.bot_commands[cmd]) then
|
if (not mt_irc.bot_commands[cmd]) then
|
||||||
irc.say(from, "Unknown command `"..cmd.."'. Try `!help'.");
|
mt_irc.say(from, "Unknown command `"..cmd.."'. Try `!help'.");
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -80,14 +94,11 @@ irc.register_callback("private_msg", function ( from, message )
|
|||||||
end);
|
end);
|
||||||
|
|
||||||
irc.register_callback("kick", function ( chaninfo, to, from )
|
irc.register_callback("kick", function ( chaninfo, to, from )
|
||||||
if (mt_irc.connect_ok) then
|
minetest.chat_send_all("IRC: Bot was kicked by "..from..". Reconnecting bot in 5 seconds...");
|
||||||
mt_irc.connect_ok = false;
|
mt_irc.got_motd = false;
|
||||||
minetest.chat_send_all("IRC: Bot was kicked by "..from..". Reconnecting bot in 5 seconds...");
|
mt_irc.connect_ok = false;
|
||||||
mt_irc.got_motd = true;
|
irc.quit("Kicked");
|
||||||
mt_irc.connect_ok = false;
|
minetest.after(5, mt_irc.connect);
|
||||||
irc.quit("Kicked");
|
|
||||||
minetest.after(5, mt_irc.connect);
|
|
||||||
end
|
|
||||||
end);
|
end);
|
||||||
|
|
||||||
irc.register_callback("nick_change", function ( from, old_nick )
|
irc.register_callback("nick_change", function ( from, old_nick )
|
||||||
@ -123,3 +134,11 @@ minetest.register_on_shutdown(function ( )
|
|||||||
irc.poll();
|
irc.poll();
|
||||||
end
|
end
|
||||||
end);
|
end);
|
||||||
|
|
||||||
|
irc.handlers.on_error = function (from, respond_to)
|
||||||
|
minetest.chat_send_all("IRC: Ping timeout. Reconnecting bot in 5 seconds...");
|
||||||
|
mt_irc.got_motd = false;
|
||||||
|
mt_irc.connect_ok = false;
|
||||||
|
irc.quit("Ping timeout");
|
||||||
|
minetest.after(5, mt_irc.connect);
|
||||||
|
end
|
||||||
|
@ -1,4 +1,18 @@
|
|||||||
|
|
||||||
|
-- IRC Mod for Minetest
|
||||||
|
-- By Diego Martínez <kaeza@users.sf.net>
|
||||||
|
--
|
||||||
|
-- This mod allows to tie a Minetest server to an IRC channel.
|
||||||
|
--
|
||||||
|
-- This program is free software. It comes without any warranty, to
|
||||||
|
-- the extent permitted by applicable law. You can redistribute it
|
||||||
|
-- and/or modify it under the terms of the Do What The Fuck You Want
|
||||||
|
-- To Public License, Version 2, as published by Sam Hocevar. See
|
||||||
|
-- http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||||
|
--
|
||||||
|
|
||||||
|
local irc = require("irc");
|
||||||
|
|
||||||
minetest.register_chatcommand("msg", {
|
minetest.register_chatcommand("msg", {
|
||||||
params = "<name> <message>";
|
params = "<name> <message>";
|
||||||
description = "Send a private message to an IRC user";
|
description = "Send a private message to an IRC user";
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
|
||||||
|
-- IRC Mod for Minetest
|
||||||
|
-- By Diego Martínez <kaeza@users.sf.net>
|
||||||
|
--
|
||||||
|
-- This mod allows to tie a Minetest server to an IRC channel.
|
||||||
|
--
|
||||||
|
-- This program is free software. It comes without any warranty, to
|
||||||
|
-- the extent permitted by applicable law. You can redistribute it
|
||||||
|
-- and/or modify it under the terms of the Do What The Fuck You Want
|
||||||
|
-- To Public License, Version 2, as published by Sam Hocevar. See
|
||||||
|
-- http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||||
|
--
|
||||||
|
|
||||||
-- *************************
|
-- *************************
|
||||||
-- ** BASIC USER SETTINGS **
|
-- ** BASIC USER SETTINGS **
|
||||||
-- *************************
|
-- *************************
|
||||||
@ -8,7 +21,7 @@ mt_irc.server = nil;
|
|||||||
-- Port to connect on joinplayer (number, default 6667)
|
-- Port to connect on joinplayer (number, default 6667)
|
||||||
mt_irc.port = nil;
|
mt_irc.port = nil;
|
||||||
|
|
||||||
-- Channel to connect on joinplayer (string, default "#minetest-irc-testing")
|
-- Channel to connect on joinplayer (string, default "##mt-irc-mod")
|
||||||
mt_irc.channel = nil;
|
mt_irc.channel = nil;
|
||||||
|
|
||||||
-- ***********************
|
-- ***********************
|
||||||
@ -23,7 +36,7 @@ mt_irc.timeout = nil;
|
|||||||
|
|
||||||
-- Nickname when using single conection (string, default "minetest-"..<server-id>);
|
-- Nickname when using single conection (string, default "minetest-"..<server-id>);
|
||||||
-- (<server-id> is the server IP address packed as a 32 bit integer).
|
-- (<server-id> is the server IP address packed as a 32 bit integer).
|
||||||
mt_irc.server_nick = nil;
|
mt_irc.server_nick = "HelloIRC";
|
||||||
|
|
||||||
-- Password to use when using single connection (string, default "")
|
-- Password to use when using single connection (string, default "")
|
||||||
mt_irc.password = nil;
|
mt_irc.password = nil;
|
||||||
|
@ -1,4 +1,16 @@
|
|||||||
|
|
||||||
|
-- IRC Mod for Minetest
|
||||||
|
-- By Diego Martínez <kaeza@users.sf.net>
|
||||||
|
--
|
||||||
|
-- This mod allows to tie a Minetest server to an IRC channel.
|
||||||
|
--
|
||||||
|
-- This program is free software. It comes without any warranty, to
|
||||||
|
-- the extent permitted by applicable law. You can redistribute it
|
||||||
|
-- and/or modify it under the terms of the Do What The Fuck You Want
|
||||||
|
-- To Public License, Version 2, as published by Sam Hocevar. See
|
||||||
|
-- http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||||
|
--
|
||||||
|
|
||||||
-- TODO
|
-- TODO
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
-- IRC Mod for Minetest
|
-- IRC Mod for Minetest
|
||||||
-- (C) 2012 Diego Martínez <kaeza@users.sf.net>
|
-- By Diego Martínez <kaeza@users.sf.net>
|
||||||
--
|
--
|
||||||
-- This mod allows to tie a Minetest server to an IRC channel.
|
-- This mod allows to tie a Minetest server to an IRC channel.
|
||||||
--
|
--
|
||||||
@ -142,7 +143,7 @@ mt_irc.say = function ( to, msg )
|
|||||||
irc.say(to, msg);
|
irc.say(to, msg);
|
||||||
end
|
end
|
||||||
|
|
||||||
mt_irc._irc = irc;
|
mt_irc.irc = irc;
|
||||||
|
|
||||||
dofile(MODPATH.."/callback.lua");
|
dofile(MODPATH.."/callback.lua");
|
||||||
dofile(MODPATH.."/chatcmds.lua");
|
dofile(MODPATH.."/chatcmds.lua");
|
||||||
|
@ -43,11 +43,11 @@ local icallbacks = {
|
|||||||
ctcp_version = {},
|
ctcp_version = {},
|
||||||
}
|
}
|
||||||
local requestinfo = {whois = {}}
|
local requestinfo = {whois = {}}
|
||||||
local handlers = {}
|
handlers = {}
|
||||||
local ctcp_handlers = {}
|
ctcp_handlers = {}
|
||||||
local user_handlers = {}
|
user_handlers = {}
|
||||||
local serverinfo = {}
|
serverinfo = {}
|
||||||
local ip = nil
|
ip = nil
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- defaults {{{
|
-- defaults {{{
|
||||||
|
Loading…
Reference in New Issue
Block a user