degesch; fix handling of CTCP requests
This commit is contained in:
parent
955b3728a3
commit
1dd464f35c
20
degesch.c
20
degesch.c
|
@ -5471,27 +5471,31 @@ irc_handle_ctcp_request (struct server *s,
|
||||||
{
|
{
|
||||||
const char *target = msg->params.vector[0];
|
const char *target = msg->params.vector[0];
|
||||||
if (irc_is_this_us (s, msg->prefix))
|
if (irc_is_this_us (s, msg->prefix))
|
||||||
|
{
|
||||||
|
if (s->cap_echo_message)
|
||||||
log_ctcp_query (s, target, chunk->tag.str);
|
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,
|
log_server_status (s, s->buffer,
|
||||||
"CTCP requested by #n: #S", msg->prefix, chunk->tag.str);
|
"CTCP requested by #n: #S", msg->prefix, chunk->tag.str);
|
||||||
|
|
||||||
char *recipient = irc_is_channel (s, target)
|
char *nickname = irc_cut_nickname (msg->prefix);
|
||||||
? irc_cut_nickname (msg->prefix)
|
|
||||||
: xstrdup (target);
|
|
||||||
|
|
||||||
if (!strcmp (chunk->tag.str, "CLIENTINFO"))
|
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");
|
"PING", "VERSION", "TIME", "CLIENTINFO");
|
||||||
else if (!strcmp (chunk->tag.str, "PING"))
|
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"))
|
else if (!strcmp (chunk->tag.str, "VERSION"))
|
||||||
{
|
{
|
||||||
struct utsname info;
|
struct utsname info;
|
||||||
if (uname (&info))
|
if (uname (&info))
|
||||||
LOG_LIBC_FAILURE ("uname");
|
LOG_LIBC_FAILURE ("uname");
|
||||||
else
|
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);
|
PROGRAM_NAME, PROGRAM_VERSION, info.sysname, info.machine);
|
||||||
}
|
}
|
||||||
else if (!strcmp (chunk->tag.str, "TIME"))
|
else if (!strcmp (chunk->tag.str, "TIME"))
|
||||||
|
@ -5500,10 +5504,10 @@ irc_handle_ctcp_request (struct server *s,
|
||||||
if (!ctime_now (buf))
|
if (!ctime_now (buf))
|
||||||
LOG_LIBC_FAILURE ("asctime_r");
|
LOG_LIBC_FAILURE ("asctime_r");
|
||||||
else
|
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
|
static void
|
||||||
|
|
Loading…
Reference in New Issue