From 8693044511a2129a3b24c9fd7c20f38972c971f3 Mon Sep 17 00:00:00 2001 From: Arnaud Cornet Date: Fri, 26 Dec 2008 08:56:03 +0100 Subject: [PATCH] fix notice logging file storage --- src/irc.c | 7 +++++-- src/log.c | 23 ++++++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/irc.c b/src/irc.c index e79f211..6f31124 100644 --- a/src/irc.c +++ b/src/irc.c @@ -880,6 +880,8 @@ static int irc_cli_notice(struct link_client *ic, struct line *line) return OK_FORGET; log_cli_notice(LINK(ic)->log, LINK(ic)->l_server->nick, irc_line_elem(line, 1), irc_line_elem(line, 2)); + if (LINK(ic)->user->blreset_on_talk) + log_reinit_all(LINK(ic)->log); return OK_COPY_CLI; } @@ -1784,16 +1786,17 @@ static int irc_privmsg(struct link_server *server, struct line *line) { if (!irc_line_includes(line, 2)) return ERR_PROTOCOL; - if (LINK(server)->s_state == IRCS_CONNECTED) { + if (LINK(server)->s_state == IRCS_CONNECTED) log_privmsg(LINK(server)->log, line->origin, irc_line_elem(line, 1), irc_line_elem(line, 2)); - } irc_privmsg_check_ctcp(server, line); return OK_COPY; } static int irc_notice(struct link_server *server, struct line *line) { + if (!irc_line_includes(line, 2)) + return ERR_PROTOCOL; if (LINK(server)->s_state == IRCS_CONNECTED) log_notice(LINK(server)->log, line->origin, irc_line_elem(line, 1), irc_line_elem(line, 2)); diff --git a/src/log.c b/src/log.c index 1faabd1..1965309 100644 --- a/src/log.c +++ b/src/log.c @@ -524,15 +524,17 @@ void log_cli_privmsg(log_t *logdata, const char *ircmask, do_log_privmsg(logdata, destination, 1, ircmask, message); } -static void _log_notice(log_t *logdata, const char *ircmask, int src, - const char *destination, const char *message) +#if 0 +static void do_log_notice(log_t *logdata, const char *storate, int src, + const char *from, const char *message) { char dir = '<'; - if (!ircmask) - ircmask = "Server message"; + if (!from) + from = "Server message"; if (src) dir = '>'; + if (*message == '\001' && *(message + strlen(message) - 1) == '\001') return; if (ischannel(*destination) || strchr(destination, '@')) { @@ -543,19 +545,26 @@ static void _log_notice(log_t *logdata, const char *ircmask, int src, "%s %c %s (%s): %s", timestamp(), dir, ircmask, destination, message); } - log_write(logdata, destination, logdata->buffer); + log_write(logdata, storage, logdata->buffer); } +#endif void log_notice(log_t *logdata, const char *ircmask, const char *destination, const char *message) { - _log_notice(logdata, ircmask, 0, destination, message); + if (!ischannel(*destination)) { + char *nick = nick_from_ircmask(ircmask); + do_log_privmsg(logdata, nick, 0, ircmask, message); + free(nick); + } else { + do_log_privmsg(logdata, destination, 0, ircmask, message); + } } void log_cli_notice(log_t *logdata, const char *ircmask, const char *destination, const char *message) { - _log_notice(logdata, ircmask, 1, destination, message); + do_log_privmsg(logdata, destination, 1, ircmask, message); } void log_topic(log_t *logdata, const char *ircmask, const char *channel,