~aleteoryx/sexchat

a1d5bb4e9ff16980bbbd8d886b1528f1021fc13f — Aleteoryx 4 months ago b4678b2
restrict self-sent CTCP handling
1 files changed, 19 insertions(+), 14 deletions(-)

M src/common/ctcp.c
M src/common/ctcp.c => src/common/ctcp.c +19 -14
@@ 93,21 93,9 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip,
	server *serv = sess->server;
	char outbuf[1024];
	int ctcp_offset = 2;

	/* 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], IG_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. */
	   ignore as if it was a PRIV/CHAN. */
	if (!g_ascii_strncasecmp (msg, "ACTION ", 7))
	{
		if (is_channel (serv, to))


@@ 129,6 117,23 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip,
		inbound_action (sess, to, nick, ip, msg + 7, FALSE, tags_data->identified, tags_data);
		return;
	}
	
	// ignore CTCPs if they're from us
	// FIXME: this might fuck with plugins that care about CTCPs, especially custom ones
	if (g_ascii_strcasecmp (to, serv->nick) != 0 && g_ascii_strcasecmp (nick, serv->nick) == 0)
		return;
	
	/* 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], IG_DCC))
				handle_dcc (sess, nick, word, word_eol, tags_data);
		}
		return;
	}

	if (ignore_check (word[1], IG_CTCP))
		return;