degesch: show mode changes

This commit is contained in:
Přemysl Eric Janouch 2015-05-21 19:57:12 +02:00
parent 0260fcd02e
commit b0dbc34f9a
1 changed files with 43 additions and 1 deletions

View File

@ -3828,8 +3828,50 @@ irc_handle_kick (struct server *s, const struct irc_message *msg)
static void
irc_handle_mode (struct server *s, const struct irc_message *msg)
{
if (!msg->prefix || msg->params.len < 1)
return;
char *who = irc_cut_nickname (msg->prefix);
const char *context = msg->params.vector[0];
// Join the modes back to a single string
struct str_vector copy;
str_vector_init (&copy);
str_vector_add_vector (&copy, msg->params.vector + 1);
char *reconstructed = join_str_vector (&copy, ' ');
str_vector_free (&copy);
char *modes = irc_to_utf8 (s->ctx, reconstructed);
free (reconstructed);
// TODO: parse the mode change and apply it
// TODO: log a message
if (irc_is_channel (s, context))
{
struct channel *channel = str_map_find (&s->irc_channels, context);
struct buffer *buffer = str_map_find (&s->irc_buffer_map, context);
hard_assert ((channel && buffer) ||
(channel && !buffer) || (!channel && !buffer));
// FIXME: logging
if (buffer)
{
buffer_send_status (s->ctx, buffer,
"Mode %s [%s] by %s", context, modes, who);
}
}
else if (irc_is_this_us (s, context))
{
// FIXME: logging
buffer_send_status (s->ctx, s->buffer,
"User mode [%s] by %s", modes, who);
}
else
{
// XXX: this shouldn't happen, reconnect?
}
free (who);
free (modes);
}
static void