diff options
author | Timo Sirainen <cras@irssi.org> | 2000-05-15 15:22:28 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-05-15 15:22:28 +0000 |
commit | ffaab13c8b2189956b841ec9fa3a25a4dafc4a03 (patch) | |
tree | 4e64834964c67ad98742376d3d88941b520fadaf | |
parent | b7074d74019c74f1515a0ebcd0831e54625bbc9a (diff) | |
download | irssi-ffaab13c8b2189956b841ec9fa3a25a4dafc4a03.zip |
Irssi will reply to CTCP TIME request.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@222 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r-- | src/irc/core/ctcp.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/irc/core/ctcp.c b/src/irc/core/ctcp.c index 55df8098..31768088 100644 --- a/src/irc/core/ctcp.c +++ b/src/irc/core/ctcp.c @@ -86,6 +86,27 @@ static void ctcp_version(const char *data, IRC_SERVER_REC *server, const char *n g_free(reply); } +/* CTCP version */ +static void ctcp_time(const char *data, IRC_SERVER_REC *server, const char *nick) +{ + char *str, *reply; + struct tm *tm; + time_t t; + + g_return_if_fail(server != NULL); + g_return_if_fail(nick != NULL); + + t = time(NULL); + tm = localtime(&t); + reply = g_strdup(asctime(tm)); + if (reply[strlen(reply)-1] == '\n') reply[strlen(reply)-1] = '\0'; + + str = g_strdup_printf("NOTICE %s :\001TIME %s\001", nick, reply); + ctcp_send_reply(server, str); + g_free(str); + g_free(reply); +} + static void ctcp_msg(const char *data, IRC_SERVER_REC *server, const char *nick, const char *addr, const char *target) { char *args, *str; @@ -178,6 +199,7 @@ void ctcp_init(void) signal_add("ctcp reply", (SIGNAL_FUNC) ctcp_reply); signal_add("ctcp msg ping", (SIGNAL_FUNC) ctcp_ping); signal_add("ctcp msg version", (SIGNAL_FUNC) ctcp_version); + signal_add("ctcp msg time", (SIGNAL_FUNC) ctcp_time); } void ctcp_deinit(void) @@ -189,4 +211,5 @@ void ctcp_deinit(void) signal_remove("ctcp reply", (SIGNAL_FUNC) ctcp_reply); signal_remove("ctcp msg ping", (SIGNAL_FUNC) ctcp_ping); signal_remove("ctcp msg version", (SIGNAL_FUNC) ctcp_version); + signal_remove("ctcp msg time", (SIGNAL_FUNC) ctcp_time); } |