mirror of
https://github.com/ShadowNinja/LuaIRC.git
synced 2025-01-09 09:30:28 +01:00
Generate a new nick if it is used or erroneous
This commit is contained in:
parent
bc79606de0
commit
a79c9451f6
@ -25,8 +25,9 @@
|
||||
module "irc"
|
||||
|
||||
--- Create a new IRC object. Use <code>irc:connect</code> to connect to a server.
|
||||
-- @param user Table with fields <code>nick</code>, <code>username</code> and <code>realname</code>.
|
||||
-- @param user Table with fields <code>nick</code>, <code>username</code>, <code>realname</code>, and <code>nick_generator</code>.
|
||||
-- The <code>nick</code> field is required.
|
||||
-- The <code>nick_generator</code> field is a fuction that should return a new nick name given the old one.
|
||||
--
|
||||
-- @return Returns a new <code>irc</code> object.
|
||||
function new(user)
|
||||
|
12
handlers.lua
12
handlers.lua
@ -96,6 +96,18 @@ handlers["366"] = function(o, prefix, me, channel, msg)
|
||||
end
|
||||
end
|
||||
|
||||
local function handle_bad_nick(o, prefix, x, badnick)
|
||||
o.nick = o.nick_generator(badnick)
|
||||
o.send("NICK %s", o.nick)
|
||||
o.send("USER %s 0 * :%s", o.username, o.realname)
|
||||
end
|
||||
|
||||
-- ERR_ERRONEOUSNICKNAME
|
||||
handlers["432"] = handle_bad_nick
|
||||
|
||||
-- ERR_NICKNAMEINUSE
|
||||
handlers["433"] = handle_bad_nick
|
||||
|
||||
--no topic
|
||||
handlers["331"] = function(o, prefix, me, channel)
|
||||
o:invoke("OnTopic", channel, nil)
|
||||
|
Loading…
Reference in New Issue
Block a user