summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--degesch.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/degesch.c b/degesch.c
index 021b5ed..6aff5f7 100644
--- a/degesch.c
+++ b/degesch.c
@@ -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