summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-05-21 19:57:12 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-05-21 19:59:37 +0200
commitb0dbc34f9a0180caf90a2d3ea98e79399435c0c5 (patch)
treed175d59df529fc60fc8b10b4a5cc96c4ccc0cd38
parent0260fcd02ef0ea7c7538099c398d2a2161f3d856 (diff)
downloadxK-b0dbc34f9a0180caf90a2d3ea98e79399435c0c5.tar.gz
xK-b0dbc34f9a0180caf90a2d3ea98e79399435c0c5.tar.xz
xK-b0dbc34f9a0180caf90a2d3ea98e79399435c0c5.zip
degesch: show mode changes
-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