forked from minetest-mods/irc
Reconnect with a different nickname if the original is already in use
This commit is contained in:
parent
96ed8287f4
commit
33a16ac395
@ -4,6 +4,7 @@ TODO List
|
||||
|
||||
- Check for availability of nickname on join, and select a different one
|
||||
until one is available.
|
||||
- Implement more callbacks for `mt_irc.register_callback'.
|
||||
|
||||
Not TODO List
|
||||
-------------
|
||||
|
@ -1,2 +1,7 @@
|
||||
#! /bin/sh
|
||||
(cd Build && cmake . && make && make pack_mod && rm -fr ~/.minetest/games/testing/mods/irc && cp -fr irc ~/.minetest/games/testing/mods/ )
|
||||
cd Build \
|
||||
&& cmake .. \
|
||||
&& make \
|
||||
&& make pack_mod \
|
||||
&& rm -fr ~/.minetest/games/testing/mods/irc \
|
||||
&& cp -fr irc ~/.minetest/games/testing/mods/
|
||||
|
@ -183,12 +183,29 @@ minetest.register_on_shutdown(function ( )
|
||||
end
|
||||
end);
|
||||
|
||||
irc.handlers.on_error = function (from, respond_to)
|
||||
irc.handlers.on_error = function (...) --( from, respond_to )
|
||||
for k, v in pairs(mt_irc.connected_players) do
|
||||
if (v) then minetest.chat_send_player(k, text); end
|
||||
if (v) then minetest.chat_send_player(k, "IRC: Bot had a network error. Reconnecting in 5 seconds..."); end
|
||||
end
|
||||
for _, v in ipairs({...}) do
|
||||
minetest.chat_send_all(dump(v));
|
||||
end
|
||||
irc.quit("Network error");
|
||||
for n = 1, 5 do
|
||||
irc.poll();
|
||||
end
|
||||
mt_irc.got_motd = false;
|
||||
mt_irc.connect_ok = false;
|
||||
irc.quit("Ping timeout");
|
||||
minetest.after(5, mt_irc.connect);
|
||||
end
|
||||
|
||||
irc.handlers.on_err_nicknameinuse = function ( from, respond_to )
|
||||
irc.quit("Nick in use");
|
||||
for n = 1, 5 do
|
||||
irc.poll();
|
||||
end
|
||||
mt_irc.got_motd = false;
|
||||
mt_irc.connect_ok = false;
|
||||
mt_irc.server_nick = mt_irc.server_nick:sub(1, -2)..math.floor(math.random(10));
|
||||
mt_irc.connect();
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user