diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-06-02 23:31:44 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-06-02 23:31:44 +0200 |
commit | 458ac8b7c4dde49ddde3dfa4335fb717e2d2f5e0 (patch) | |
tree | 8688509cb58f0424f8d4254ba332a2438dbe663d /degesch.c | |
parent | b132b979da9f7afeee4f3f4fb9720a16f38c5868 (diff) | |
download | xK-458ac8b7c4dde49ddde3dfa4335fb717e2d2f5e0.tar.gz xK-458ac8b7c4dde49ddde3dfa4335fb717e2d2f5e0.tar.xz xK-458ac8b7c4dde49ddde3dfa4335fb717e2d2f5e0.zip |
degesch: try to log lines in more specific buffers
Diffstat (limited to 'degesch.c')
-rw-r--r-- | degesch.c | 55 |
1 files changed, 43 insertions, 12 deletions
@@ -4663,14 +4663,7 @@ irc_process_numeric (struct server *s, str_vector_init (©); str_vector_add_vector (©, msg->params.vector + !!msg->params.len); - // Join the parameter vector back, recode it to our internal encoding - // and send it to the server buffer - char *reconstructed = join_str_vector (©, ' '); - str_vector_free (©); - buffer_send (s->ctx, s->buffer, BUFFER_LINE_STATUS, 0, - .text = irc_to_utf8 (s->ctx, reconstructed)); - free (reconstructed); - + struct buffer *buffer = s->buffer; switch (numeric) { case IRC_RPL_WELCOME: @@ -4681,15 +4674,53 @@ irc_process_numeric (struct server *s, irc_try_parse_welcome_for_userhost (s, msg->params.vector[1]); break; - case IRC_RPL_ISUPPORT: irc_handle_rpl_isupport (s, msg); break; - case IRC_RPL_USERHOST: irc_handle_rpl_userhost (s, msg); break; - case IRC_RPL_NAMREPLY: irc_handle_rpl_namreply (s, msg); break; - case IRC_RPL_ENDOFNAMES: irc_handle_rpl_endofnames (s, msg); break; + case IRC_RPL_ISUPPORT: + irc_handle_rpl_isupport (s, msg); break; + case IRC_RPL_USERHOST: + irc_handle_rpl_userhost (s, msg); break; + case IRC_RPL_NAMREPLY: + irc_handle_rpl_namreply (s, msg); buffer = NULL; break; + case IRC_RPL_ENDOFNAMES: + irc_handle_rpl_endofnames (s, msg); buffer = NULL; break; case IRC_ERR_NICKNAMEINUSE: // TODO: if (state == IRC_CONNECTED), use a different nick; // either use a number suffix, or accept commas in "nickname" config break; + + case IRC_RPL_LIST: + case IRC_RPL_WHOREPLY: + case IRC_RPL_ENDOFWHO: + + case IRC_ERR_UNKNOWNCOMMAND: + case IRC_ERR_NEEDMOREPARAMS: + // Just preventing these commands from getting printed in a more + // specific buffer as that would be unwanted + break; + + default: + // If the second parameter is something we have a buffer for + // (a channel, a PM buffer), log it in that buffer. This is very basic + // and we should whitelist/blacklist a lot more replies here. + // TODO: if this happens, we should either strip the first parameter + // from the buffer line, or at least put it in brackets + if (msg->params.len > 1) + { + struct buffer *x; + if ((x = str_map_find (&s->irc_buffer_map, msg->params.vector[1]))) + buffer = x; + } + } + + if (buffer) + { + // Join the parameter vector back, recode it to our internal encoding + // and send it to the server buffer + char *reconstructed = join_str_vector (©, ' '); + str_vector_free (©); + buffer_send (s->ctx, buffer, BUFFER_LINE_STATUS, 0, + .text = irc_to_utf8 (s->ctx, reconstructed)); + free (reconstructed); } } |