From 5e4f94c38c2078655a3e314d49926d6b05830ea1 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Tue, 2 Jun 2015 23:42:04 +0200
Subject: degesch: log the channel topic after joining
---
degesch.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/degesch.c b/degesch.c
index ee5540f..ffac775 100644
--- a/degesch.c
+++ b/degesch.c
@@ -4517,6 +4517,27 @@ irc_handle_rpl_endofnames (struct server *s, const struct irc_message *msg)
irc_process_names (s, channel);
}
+static void
+irc_handle_rpl_topic (struct server *s, const struct irc_message *msg)
+{
+ if (msg->params.len < 3)
+ return;
+
+ const char *channel_name = msg->params.vector[1];
+ const char *topic = msg->params.vector[2];
+
+ struct channel *channel = str_map_find (&s->irc_channels, channel_name);
+ struct buffer *buffer = str_map_find (&s->irc_buffer_map, channel_name);
+ hard_assert ((channel && buffer) ||
+ (channel && !buffer) || (!channel && !buffer));
+
+ if (buffer)
+ {
+ // FIXME: logging
+ buffer_send_status (s->ctx, buffer, "The topic is: %s", topic);
+ }
+}
+
static void
irc_handle_isupport_prefix (struct server *s, char *value)
{
@@ -4682,6 +4703,8 @@ irc_process_numeric (struct server *s,
irc_handle_rpl_namreply (s, msg); buffer = NULL; break;
case IRC_RPL_ENDOFNAMES:
irc_handle_rpl_endofnames (s, msg); buffer = NULL; break;
+ case IRC_RPL_TOPIC:
+ irc_handle_rpl_topic (s, msg); buffer = NULL; break;
case IRC_ERR_NICKNAMEINUSE:
// TODO: if (state == IRC_CONNECTED), use a different nick;
--
cgit v1.2.3-70-g09d2