void ctcp_handle (session *sess, char *to, char *nick, char *msg, char *word[], char *word_eol[], int id) { char *po; session *chansess; server *serv = sess->server; char outbuf[1024]; /* consider DCC to be different from other CTCPs */ if (!strncasecmp (msg, "DCC", 3)) { /* but still let CTCP replies override it */ if (!ctcp_check (sess, nick, word, word_eol, word[4] + 2)) { if (!ignore_check (word[1], IG_DCC)) handle_dcc (sess, nick, word, word_eol); } return; } /* consider ACTION to be different from other CTCPs. Check ignore as if it was a PRIV/CHAN. */ if (!strncasecmp (msg, "ACTION ", 7)) { if (is_channel (serv, to)) { /* treat a channel action as a CHAN */ if (ignore_check (word[1], IG_CHAN)) return; } else { /* treat a private action as a PRIV */ if (ignore_check (word[1], IG_PRIV)) return; } /* but still let CTCP replies override it */ if (ctcp_check (sess, nick, word, word_eol, word[4] + 2)) goto generic; inbound_action (sess, to, nick, msg + 7, FALSE, id); return; } if (ignore_check (word[1], IG_CTCP)) return; if (!strcasecmp (msg, "VERSION") && !prefs.hidever) { #ifdef FE_AQUA snprintf (outbuf, sizeof (outbuf), "VERSION X-Chat Aqua %s (xchat "PACKAGE_VERSION") %s", prefs.xchat_aqua_version, get_cpu_str ()); #else snprintf (outbuf, sizeof (outbuf), "VERSION xchat "PACKAGE_VERSION" %s", get_cpu_str ()); #endif serv->p_nctcp (serv, nick, outbuf); } if (!ctcp_check (sess, nick, word, word_eol, word[4] + 2)) { if (!strncasecmp (msg, "SOUND", 5)) { po = strchr (word[5], '\001'); if (po) po[0] = 0; if (is_channel (sess->server, to)) { chansess = find_channel (sess->server, to); if (!chansess) chansess = sess; EMIT_SIGNAL (XP_TE_CTCPSNDC, chansess, word[5], nick, to, NULL, 0); } else { EMIT_SIGNAL (XP_TE_CTCPSND, sess->server->front_session, word[5], nick, NULL, NULL, 0); } /* don't let IRCers specify path */ #ifdef WIN32 if (strchr (word[5], '/') == NULL && strchr (word[5], '\\') == NULL) #else if (strchr (word[5], '/') == NULL) #endif sound_play (word[5], TRUE); return; } } generic: po = strchr (msg, '\001'); if (po) po[0] = 0; if (!is_channel (sess->server, to)) { EMIT_SIGNAL (XP_TE_CTCPGEN, sess->server->front_session, msg, nick, NULL, NULL, 0); } else { chansess = find_channel (sess->server, to); if (!chansess) chansess = sess; EMIT_SIGNAL (XP_TE_CTCPGENC, chansess, msg, nick, to, NULL, 0); } }
void handle_ctcp (struct session *sess, char *outbuf, char *to, char *nick, char *msg, char *word[], char *word_eol[]) { char *po; session *chansess; if (!strncasecmp (msg, "VERSION", 7) && !prefs.hidever) { sprintf (outbuf, "NOTICE %s :\001VERSION xchat "VERSION" %s (PicoGUI)\001\r\n", nick, get_cpu_str ()); tcp_send (sess->server, outbuf); } if (!ctcp_check (sess, outbuf, nick, word, word_eol, word[4] + 2)) { if (!strncasecmp (msg, "ACTION", 6)) { po = strchr (msg + 7, '\001'); if (po) po[0] = 0; channel_action (sess, outbuf, to, nick, msg + 7, FALSE); return; } if (!strncasecmp (msg, "DCC", 3)) { handle_dcc (sess, outbuf, nick, word, word_eol); return; } if (!strncasecmp (msg, "SOUND", 5)) { po = strchr (word[5], '\001'); if (po) po[0] = 0; EMIT_SIGNAL (XP_TE_CTCPSND, sess->server->front_session, word[5], nick, NULL, NULL, 0); sprintf (outbuf, "%s/%s", prefs.sounddir, word[5]); if (strchr (word[5], '/') == 0 && access (outbuf, R_OK) == 0) { sprintf (outbuf, "%s %s/%s", prefs.soundcmd, prefs.sounddir, word[5]); xchat_exec (outbuf); } return; } } po = strchr (msg, '\001'); if (po) po[0] = 0; if (!is_channel (sess->server, to)) { EMIT_SIGNAL (XP_TE_CTCPGEN, sess->server->front_session, msg, nick, NULL, NULL, 0); } else { chansess = find_session_from_channel (to, sess->server); if (chansess) { EMIT_SIGNAL (XP_TE_CTCPGENC, chansess, msg, nick, to, NULL, 0); return; } EMIT_SIGNAL (XP_TE_CTCPGENC, sess->server->front_session, msg, nick, to, NULL, 0); } }
void ctcp_handle (session *sess, char *to, char *nick, char *ip, char *msg, char *word[], char *word_eol[], bool id, const message_tags_data *tags_data) { char *po; session *chansess; server *serv = sess->server; char outbuf[1024]; int ctcp_offset = 2; if (serv->have_idmsg && (word[4][1] == '+' || word[4][1] == '-') ) ctcp_offset = 3; /* consider DCC to be different from other CTCPs */ if (!g_ascii_strncasecmp (msg, "DCC", 3)) { /* but still let CTCP replies override it */ if (!ctcp_check (sess, nick, word, word_eol, word[4] + ctcp_offset)) { if (!ignore_check(word[1], ignore::IG_DCC)) dcc::handle_dcc (sess, nick, word, word_eol, tags_data); } return; } /* consider ACTION to be different from other CTCPs. Check ignore as if it was a PRIV/CHAN. */ if (!g_ascii_strncasecmp (msg, "ACTION ", 7)) { if (serv->is_channel_name (to)) { /* treat a channel action as a CHAN */ if (ignore_check(word[1], ignore::IG_CHAN)) return; } else { /* treat a private action as a PRIV */ if (ignore_check(word[1], ignore::IG_PRIV)) return; } /* but still let CTCP replies override it */ if (ctcp_check (sess, nick, word, word_eol, word[4] + ctcp_offset)) goto generic; inbound_action (sess, to, nick, ip, msg + 7, false, id, tags_data); return; } if (ignore_check(word[1], ignore::IG_CTCP)) return; if (!g_ascii_strcasecmp (msg, "VERSION") && !prefs.hex_irc_hide_version) { #ifdef WIN32 snprintf (outbuf, sizeof (outbuf), "VERSION HexChat " PACKAGE_VERSION " [x%d] / %s", get_cpu_arch (), get_sys_str (true)); #else snprintf (outbuf, sizeof (outbuf), "VERSION HexChat " PACKAGE_VERSION " / %s", get_sys_str (true)); #endif serv->p_nctcp (nick, outbuf); } if (!ctcp_check (sess, nick, word, word_eol, word[4] + ctcp_offset)) { if (!g_ascii_strncasecmp (msg, "SOUND", 5)) { po = std::strchr (word[5], '\001'); if (po) po[0] = 0; if (sess->server->is_channel_name(to)) { chansess = find_channel (*(sess->server), to); if (!chansess) chansess = sess; EMIT_SIGNAL_TIMESTAMP (XP_TE_CTCPSNDC, chansess, word[5], nick, to, nullptr, 0, tags_data->timestamp); } else { EMIT_SIGNAL_TIMESTAMP (XP_TE_CTCPSND, sess->server->front_session, word[5], nick, nullptr, nullptr, 0, tags_data->timestamp); } /* don't let IRCers specify path */ #ifdef WIN32 if (std::strchr (word[5], '/') == nullptr && std::strchr (word[5], '\\') == nullptr) #else if (std::strchr (word[5], '/') == nullptr) #endif sound_play (word[5], true); return; } } generic: po = std::strchr (msg, '\001'); if (po) po[0] = 0; if (!sess->server->is_channel_name (to)) { EMIT_SIGNAL_TIMESTAMP (XP_TE_CTCPGEN, sess->server->front_session, msg, nick, nullptr, nullptr, 0, tags_data->timestamp); } else { chansess = find_channel (*(sess->server), to); if (!chansess) chansess = sess; EMIT_SIGNAL_TIMESTAMP (XP_TE_CTCPGENC, chansess, msg, nick, to, nullptr, 0, tags_data->timestamp); } }