irctk

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

commit 73ccdd4626efd8928117dcf148518c09c0005a7e
parent c1cf47c408a600db508020823bc281bdecc01123
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Fri,  7 Sep 2012 12:26:41 +0200

fail on errors from server

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

diff --git a/irctk.c b/irctk.c @@ -20,8 +20,10 @@ #define E_SESSION 1 #define E_CONNECT 2 #define E_THREAD 3 -#define E_BADNAME 4 -#define E_BADLINE 5 +#define E_PASSWORD 4 +#define E_SERVER_ERROR 5 +#define E_BADNAME 6 +#define E_BADLINE 7 enum default_destinations {DEFAULT_FIRST, DEFAULT_LAST_IN, DEFAULT_LAST_OUT, DEFAULT_ALL}; enum event_tos {NOTHING, COMMAND, MESSAGE}; @@ -1253,6 +1255,13 @@ void manage_event (irc_session_t *session, const char *event, const char *origin irc_target_get_host(origin, args.hostname, MAX_NICK_LEN); } + if (!strcmp(event, "ERROR")) { + if (count == 1) { + die(E_SERVER_ERROR, "Error from server: %s\n", params[0]); + } else { + die(E_SERVER_ERROR, "Unspecified error from server\n"); + } + } if (atoi(event) == LIBIRC_RFC_ERR_ERRONEUSNICKNAME) { if (args.force_nick) { die(E_BADNAME, "Invalid nick\n"); @@ -1279,6 +1288,8 @@ void manage_event (irc_session_t *session, const char *event, const char *origin info("Requested nick is taken, try %s\n", args.nick); } } + } else if (atoi(event) == LIBIRC_RFC_ERR_PASSWDMISMATCH) { + die(E_PASSWORD, "Invalid or missing password when connecting to server.\n"); } else if (atoi(event) == LIBIRC_RFC_ERR_BADCHANNELKEY) { info("Cannot join %s: bad password.\n", params[1]); } else if (atoi(event) == LIBIRC_RFC_ERR_NOSUCHCHANNEL) {