summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--degesch.c55
1 files changed, 43 insertions, 12 deletions
diff --git a/degesch.c b/degesch.c
index 3efa0e2..ee5540f 100644
--- a/degesch.c
+++ b/degesch.c
@@ -4663,14 +4663,7 @@ irc_process_numeric (struct server *s,
str_vector_init (&copy);
str_vector_add_vector (&copy, 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 (&copy, ' ');
- str_vector_free (&copy);
- 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 (&copy, ' ');
+ str_vector_free (&copy);
+ buffer_send (s->ctx, buffer, BUFFER_LINE_STATUS, 0,
+ .text = irc_to_utf8 (s->ctx, reconstructed));
+ free (reconstructed);
}
}