degesch: show mode changes
This commit is contained in:
parent
0260fcd02e
commit
b0dbc34f9a
44
degesch.c
44
degesch.c
@ -3828,8 +3828,50 @@ irc_handle_kick (struct server *s, const struct irc_message *msg)
|
|||||||
static void
|
static void
|
||||||
irc_handle_mode (struct server *s, const struct irc_message *msg)
|
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 (©);
|
||||||
|
str_vector_add_vector (©, msg->params.vector + 1);
|
||||||
|
char *reconstructed = join_str_vector (©, ' ');
|
||||||
|
str_vector_free (©);
|
||||||
|
char *modes = irc_to_utf8 (s->ctx, reconstructed);
|
||||||
|
free (reconstructed);
|
||||||
|
|
||||||
// TODO: parse the mode change and apply it
|
// 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
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user