irctk

libircclient binding for scripts
git clone https://a3nm.net/git/irctk/
Log | Files | Refs | README

commit 64fa797900a188c066f438c6041eac8d939e8e57
parent 1144bd75047abbcbda779e8b3e28a34904d50363
Author: Antoine Amarilli <ant.amarilli@free.fr>
Date:   Sun, 20 Feb 2011 03:35:41 +0100

better handling of bad nicks

Diffstat:
irctk.c | 14++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/irctk.c b/irctk.c @@ -452,7 +452,7 @@ int do_cmd_msg(irc_session_t *s, const char* chan, const char* line) } else if (line[5] == ' ') { rsl = irc_cmd_quit(s, line + 6); } - } + } // TODO: invite, names, list, topic, chanmode, kick, usermode, whois, raw } else { rsl = irc_cmd_msg (s, chan, line); } @@ -561,7 +561,7 @@ void dump_event (irc_session_t * session, const char * event, const char * origi strcat (buf, params[cnt]); } - if (!strcmp(event, "432")) + if (atoi(event) == LIBIRC_RFC_ERR_ERRONEUSNICKNAME) { /* bad nick */ if (args.force_nick) @@ -574,8 +574,18 @@ void dump_event (irc_session_t * session, const char * event, const char * origi // TODO abort die(E_BADNAME, "Invalid nick!"); } + } else if (atoi(event) == LIBIRC_RFC_ERR_NICKCOLLISION || atoi(event) == LIBIRC_RFC_ERR_NICKNAMEINUSE) { + /* bad nick */ + if (args.force_nick) + { + // TODO + } else { + // TODO abort + die(E_BADNAME, "Nickname already in use!"); + } } + debug("Event \"%s\", origin: \"%s\", params: %d [%s]", event, origin ? origin : "NULL", cnt, buf); }