aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-06-07 00:39:35 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-06-07 01:23:51 +0200
commit6d720e7a1ad9b107ac9567ce6ca90850a3a8aca6 (patch)
treeaa25f01f454f42cc608fcf3e042ea9401926b820
parente1aa27c90ba4ab1931f27371a63cbc2d3e0ea735 (diff)
downloadxK-6d720e7a1ad9b107ac9567ce6ca90850a3a8aca6.tar.gz
xK-6d720e7a1ad9b107ac9567ce6ca90850a3a8aca6.tar.xz
xK-6d720e7a1ad9b107ac9567ce6ca90850a3a8aca6.zip
degesch: process RPL_CREATIONTIME
-rw-r--r--degesch.c37
-rw-r--r--kike-replies1
2 files changed, 38 insertions, 0 deletions
diff --git a/degesch.c b/degesch.c
index 8e1404a..789ab55 100644
--- a/degesch.c
+++ b/degesch.c
@@ -4840,6 +4840,41 @@ irc_handle_rpl_channelmodeis (struct server *s, const struct irc_message *msg)
refresh_prompt (s->ctx);
}
+static char *
+make_time_string (time_t time)
+{
+ char buf[32];
+ struct tm tm;
+ strftime (buf, sizeof buf, "%a %b %d %Y %T", localtime_r (&time, &tm));
+ return xstrdup (buf);
+}
+
+static void
+irc_handle_rpl_creationtime (struct server *s, const struct irc_message *msg)
+{
+ if (msg->params.len < 3)
+ return;
+
+ const char *channel_name = msg->params.vector[1];
+ const char *creation_time = msg->params.vector[2];
+
+ unsigned long created;
+ if (!xstrtoul (&created, creation_time, 10))
+ return;
+
+ 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)
+ {
+ char *x = make_time_string (created);
+ buffer_send_status (s->ctx, buffer, "Channel created on %s", x);
+ free (x);
+ }
+}
+
static void
irc_handle_isupport_prefix (struct server *s, char *value)
{
@@ -5031,6 +5066,8 @@ irc_process_numeric (struct server *s,
irc_handle_rpl_topic (s, msg); buffer = NULL; break;
case IRC_RPL_CHANNELMODEIS:
irc_handle_rpl_channelmodeis (s, msg); buffer = NULL; break;
+ case IRC_RPL_CREATIONTIME:
+ irc_handle_rpl_creationtime (s, msg); buffer = NULL; break;
case IRC_ERR_NICKNAMEINUSE:
// TODO: if (state == IRC_CONNECTED), use a different nick;
diff --git a/kike-replies b/kike-replies
index 349f12f..d5c4b75 100644
--- a/kike-replies
+++ b/kike-replies
@@ -24,6 +24,7 @@
322 IRC_RPL_LIST "%s %d :%s"
323 IRC_RPL_LISTEND ":End of LIST"
324 IRC_RPL_CHANNELMODEIS "%s +%s"
+329 IRC_RPL_CREATIONTIME "%s %lld"
331 IRC_RPL_NOTOPIC "%s :No topic is set"
332 IRC_RPL_TOPIC "%s :%s"
346 IRC_RPL_INVITELIST "%s %s"