summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--degesch.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/degesch.c b/degesch.c
index 8221cb8..b0c87ee 100644
--- a/degesch.c
+++ b/degesch.c
@@ -277,6 +277,7 @@ enum buffer_line_type
BUFFER_LINE_PART, ///< PART
BUFFER_LINE_KICK, ///< KICK
BUFFER_LINE_NICK, ///< NICK
+ BUFFER_LINE_TOPIC, ///< TOPIC
BUFFER_LINE_QUIT, ///< QUIT
BUFFER_LINE_STATUS, ///< Whatever status messages
BUFFER_LINE_ERROR ///< Whatever error messages
@@ -926,6 +927,14 @@ buffer_line_display (struct app_context *ctx, struct buffer_line *line)
else
str_append_printf (&text, " - You are now known as %s", object);
break;
+ case BUFFER_LINE_TOPIC:
+ if (*who)
+ str_append_printf (&text,
+ " - %s has changed the topic to: %s", nick, object);
+ else
+ str_append_printf (&text,
+ " - You have changed the topic to: %s", object);
+ break;
case BUFFER_LINE_QUIT:
if (*who)
str_append_printf (&text, "<-- %s (%s) has quit (%s)",
@@ -2189,7 +2198,31 @@ irc_handle_quit (struct app_context *ctx, const struct irc_message *msg)
static void
irc_handle_topic (struct app_context *ctx, const struct irc_message *msg)
{
- // TODO: log a message
+ if (!msg->prefix || msg->params.len < 2)
+ return;
+
+ const char *channel_name = msg->params.vector[0];
+ const char *topic = msg->params.vector[1];
+ if (!irc_is_channel (ctx, channel_name))
+ return;
+
+ struct channel *channel = str_map_find (&ctx->irc_channels, channel_name);
+ struct buffer *buffer = str_map_find (&ctx->irc_buffer_map, channel_name);
+ hard_assert ((channel && buffer) ||
+ (channel && !buffer) || (!channel && !buffer));
+
+ // It would be is weird for this to be false
+ if (channel)
+ {
+ free (channel->topic);
+ channel->topic = xstrdup (topic);
+ }
+
+ if (buffer)
+ {
+ buffer_send (ctx, buffer, BUFFER_LINE_TOPIC, 0,
+ msg->prefix, NULL, "%s", topic);
+ }
}
static struct irc_handler