diff options
author | Timo Sirainen <cras@irssi.org> | 2000-11-17 14:59:32 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-11-17 14:59:32 +0000 |
commit | 2edcdd715ffd5c3ddd0009a75f8f2f451cdb9c57 (patch) | |
tree | d201bff69108b9cd914719677d3e447e29c346b0 /src/irc | |
parent | 090e88b34db29b681c7579472aafa211832d38af (diff) | |
download | irssi-2edcdd715ffd5c3ddd0009a75f8f2f451cdb9c57.zip |
Remember who set the topic and when, display the info when using /TOPIC.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@845 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/core/channel-events.c | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/src/irc/core/channel-events.c b/src/irc/core/channel-events.c index eb8a6b30..9714b38e 100644 --- a/src/irc/core/channel-events.c +++ b/src/irc/core/channel-events.c @@ -93,18 +93,28 @@ static void event_target_unavailable(const char *data, IRC_SERVER_REC *server) g_free(params); } -static void channel_change_topic(IRC_SERVER_REC *server, const char *channel, const char *topic) +static void channel_change_topic(IRC_SERVER_REC *server, const char *channel, + const char *topic, const char *setby, + time_t settime) { CHANNEL_REC *chanrec; chanrec = channel_find(SERVER(server), channel); - if (chanrec != NULL) { + if (chanrec == NULL) return; + + if (topic != NULL) { g_free_not_null(chanrec->topic); chanrec->topic = *topic == '\0' ? NULL : g_strdup(topic); - - signal_emit("channel topic changed", 1, chanrec); } + + g_free_not_null(chanrec->topic_by); + chanrec->topic_by = g_strdup(setby); + + chanrec->topic_time = settime; + + signal_emit("channel topic changed", 1, chanrec); } + static void event_topic_get(const char *data, IRC_SERVER_REC *server) { char *params, *channel, *topic; @@ -112,18 +122,34 @@ static void event_topic_get(const char *data, IRC_SERVER_REC *server) g_return_if_fail(data != NULL); params = event_get_params(data, 3, NULL, &channel, &topic); - channel_change_topic(server, channel, topic); + channel_change_topic(server, channel, topic, NULL, 0); g_free(params); } -static void event_topic(const char *data, IRC_SERVER_REC *server) +static void event_topic(const char *data, IRC_SERVER_REC *server, + const char *nick) { char *params, *channel, *topic; g_return_if_fail(data != NULL); params = event_get_params(data, 2, &channel, &topic); - channel_change_topic(server, channel, topic); + channel_change_topic(server, channel, topic, nick, time(NULL)); + g_free(params); +} + +static void event_topic_info(const char *data, IRC_SERVER_REC *server) +{ + char *params, *channel, *topicby, *topictime; + time_t t; + + g_return_if_fail(data != NULL); + + params = event_get_params(data, 4, NULL, &channel, + &topicby, &topictime); + + t = (time_t) atol(topictime); + channel_change_topic(server, channel, NULL, topicby, t); g_free(params); } @@ -283,6 +309,7 @@ void channel_events_init(void) signal_add("event kick", (SIGNAL_FUNC) event_kick); signal_add("event invite", (SIGNAL_FUNC) event_invite); signal_add("event 332", (SIGNAL_FUNC) event_topic_get); + signal_add("event 333", (SIGNAL_FUNC) event_topic_info); signal_add_first("event 437", (SIGNAL_FUNC) event_target_unavailable); /* channel/nick unavailable */ } @@ -303,5 +330,6 @@ void channel_events_deinit(void) signal_remove("event kick", (SIGNAL_FUNC) event_kick); signal_remove("event invite", (SIGNAL_FUNC) event_invite); signal_remove("event 332", (SIGNAL_FUNC) event_topic_get); + signal_remove("event 333", (SIGNAL_FUNC) event_topic_info); signal_remove("event 437", (SIGNAL_FUNC) event_target_unavailable); /* channel/nick unavailable */ } |