Compare commits
1 Commits
ad77e19bfe
...
c14f4634b6
Author | SHA1 | Date | |
---|---|---|---|
|
c14f4634b6 |
16
src/irc.c
16
src/irc.c
@ -33,6 +33,7 @@
|
||||
extern int sighup;
|
||||
extern bip_t *_bip;
|
||||
|
||||
static int irc_generic_error(struct link_server *server, struct line *line);
|
||||
static int irc_join(struct link_server *server, struct line *line);
|
||||
static int irc_part(struct link_server *server, struct line *line);
|
||||
static int irc_mode(struct link_server *server, struct line *line);
|
||||
@ -625,6 +626,10 @@ int irc_dispatch_server(bip_t *bip, struct link_server *server,
|
||||
ret = irc_quit(server, line);
|
||||
} else if (irc_line_elem_equals(line, 0, "NICK")) {
|
||||
ret = irc_nick(server, line);
|
||||
} else if (irc_line_is_error(line)) {
|
||||
// IRC errors catchall (for unhandled ones)
|
||||
// logs error to bip.log
|
||||
ret = irc_generic_error(server, line);
|
||||
}
|
||||
|
||||
if (ret == OK_COPY) {
|
||||
@ -1448,6 +1453,17 @@ static int origin_is_me(struct line *l, struct link_server *server)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int irc_generic_error(struct link_server *server, struct line *line)
|
||||
{
|
||||
if (irc_line_count(line) == 4)
|
||||
mylog(LOG_INFO, "[%s] IRC error: %s", LINK(server)->name,
|
||||
irc_line_elem(line, 3));
|
||||
else
|
||||
mylog(LOG_INFO, "[%s] IRC error: %s", LINK(server)->name,
|
||||
irc_line_to_string(line));
|
||||
return OK_COPY;
|
||||
}
|
||||
|
||||
static int irc_join(struct link_server *server, struct line *line)
|
||||
{
|
||||
char *s_nick;
|
||||
|
@ -143,6 +143,13 @@ void irc_line_drop(struct line *line, int elem)
|
||||
bip_cfree(array_drop(&line->words, elem));
|
||||
}
|
||||
|
||||
unsigned int irc_line_is_error(struct line *line)
|
||||
{
|
||||
const char *irc_code = irc_line_elem(line, 0);
|
||||
const char *error_code = "4";
|
||||
return (irc_code[0] == error_code[0]);
|
||||
}
|
||||
|
||||
int irc_line_elem_equals(struct line *line, int elem, const char *cmp)
|
||||
{
|
||||
return !strcmp(irc_line_elem(line, elem), cmp);
|
||||
|
@ -98,6 +98,7 @@ int irc_line_includes(struct line *line, int elem);
|
||||
const char *irc_line_elem(struct line *line, int elem);
|
||||
int irc_line_count(struct line *line);
|
||||
char *irc_line_pop(struct line *l);
|
||||
unsigned int irc_line_is_error(struct line *line);
|
||||
int irc_line_elem_equals(struct line *line, int elem, const char *cmp);
|
||||
int irc_line_elem_case_equals(struct line *line, int elem, const char *cmp);
|
||||
void irc_line_drop(struct line *line, int elem);
|
||||
|
Loading…
Reference in New Issue
Block a user