diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-08-06 23:00:16 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-08-06 23:23:56 +0200 |
commit | 1dd464f35c2de2379e971c0f4816549ef828cd0b (patch) | |
tree | fb8c9926a50b9b7a6b58326fd71d79de9fd2854d | |
parent | 955b3728a3d3d06449cfcebe6cee3470295d4fd0 (diff) | |
download | xK-1dd464f35c2de2379e971c0f4816549ef828cd0b.tar.gz xK-1dd464f35c2de2379e971c0f4816549ef828cd0b.tar.xz xK-1dd464f35c2de2379e971c0f4816549ef828cd0b.zip |
degesch; fix handling of CTCP requests
-rw-r--r-- | degesch.c | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -5471,27 +5471,31 @@ irc_handle_ctcp_request (struct server *s, { const char *target = msg->params.vector[0]; if (irc_is_this_us (s, msg->prefix)) - log_ctcp_query (s, target, chunk->tag.str); + { + if (s->cap_echo_message) + log_ctcp_query (s, target, chunk->tag.str); + if (!irc_is_this_us (s, target)) + return; + } + // TODO: eventually "requested by #n (to ##channel)" log_server_status (s, s->buffer, "CTCP requested by #n: #S", msg->prefix, chunk->tag.str); - char *recipient = irc_is_channel (s, target) - ? irc_cut_nickname (msg->prefix) - : xstrdup (target); + char *nickname = irc_cut_nickname (msg->prefix); if (!strcmp (chunk->tag.str, "CLIENTINFO")) - irc_send_ctcp_reply (s, recipient, "CLIENTINFO %s %s %s %s", + irc_send_ctcp_reply (s, nickname, "CLIENTINFO %s %s %s %s", "PING", "VERSION", "TIME", "CLIENTINFO"); else if (!strcmp (chunk->tag.str, "PING")) - irc_send_ctcp_reply (s, recipient, "PING %s", chunk->text.str); + irc_send_ctcp_reply (s, nickname, "PING %s", chunk->text.str); else if (!strcmp (chunk->tag.str, "VERSION")) { struct utsname info; if (uname (&info)) LOG_LIBC_FAILURE ("uname"); else - irc_send_ctcp_reply (s, recipient, "VERSION %s %s on %s %s", + irc_send_ctcp_reply (s, nickname, "VERSION %s %s on %s %s", PROGRAM_NAME, PROGRAM_VERSION, info.sysname, info.machine); } else if (!strcmp (chunk->tag.str, "TIME")) @@ -5500,10 +5504,10 @@ irc_handle_ctcp_request (struct server *s, if (!ctime_now (buf)) LOG_LIBC_FAILURE ("asctime_r"); else - irc_send_ctcp_reply (s, recipient, "TIME %s", buf); + irc_send_ctcp_reply (s, nickname, "TIME %s", buf); } - free (recipient); + free (nickname); } static void |