irctk

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

commit b10c6c21956e4898ab115bf46c93ef3fe4ffd579
parent 786d71d29b154af49b9e709bf15874d2626eec50
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Fri,  7 Sep 2012 15:22:21 +0200

do not revert to irctk on bad nick change after startup

Diffstat:
TODO | 1-
irctk.c | 15+++++++++------
2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/TODO b/TODO @@ -1,4 +1,3 @@ -- trying to change to an invalid nick after startup should fail - make ssl support work later: diff --git a/irctk.c b/irctk.c @@ -1270,7 +1270,6 @@ void manage_event (irc_session_t *session, const char *event, const char *origin } if (!strcmp(event, "ERROR")) { - //if (((irc_ctx_t *) irc_get_ctx(session))->ready) { if (count == 1) { die(E_SERVER_ERROR, "Error from server: %s\n", params[0]); } else { @@ -1279,12 +1278,16 @@ void manage_event (irc_session_t *session, const char *event, const char *origin } if (atoi(event) == LIBIRC_RFC_ERR_ERRONEUSNICKNAME) { if (args.force_nick) { - die(E_BADNAME, "Invalid nick\n"); + die(E_BADNAME, "Could not set nick\n"); } else { - // TODO should only be done during startup! - info("Invalid nick, reverting to \"irctk\"\n"); - strncpy(args.nick, "irctk", MAX_NICK_LEN-1); - rsl = irc_cmd_nick(session, "irctk"); + if (!((irc_ctx_t *) irc_get_ctx(session))->ready) { + info("Could not set nick, reverting to \"irctk\"\n"); + strncpy(args.nick, "irctk", MAX_NICK_LEN-1); + rsl = irc_cmd_nick(session, "irctk"); + } else { + info("Could not set nick, ignoring\n"); + rsl = 0; + } } } else if (atoi(event) == LIBIRC_RFC_ERR_NICKCOLLISION || atoi(event) == LIBIRC_RFC_ERR_NICKNAMEINUSE) {