diff options
| -rw-r--r-- | kike.c | 18 | 
1 files changed, 15 insertions, 3 deletions
| @@ -296,7 +296,8 @@ enum  enum  {  	IRC_CAP_MULTI_PREFIX             = (1 << 0), -	IRC_CAP_INVITE_NOTIFY            = (1 << 1) +	IRC_CAP_INVITE_NOTIFY            = (1 << 1), +	IRC_CAP_ECHO_MESSAGE             = (1 << 2)  };  struct client @@ -1145,7 +1146,8 @@ irc_handle_cap_ls (struct client *c, struct irc_cap_args *a)  			a->subcommand, "Ignoring invalid protocol version number");  	c->cap_negotiating = true; -	client_send (c, "CAP %s LS :multi-prefix invite-notify", a->target); +	client_send (c, "CAP %s LS :multi-prefix invite-notify echo-message", +		a->target);  }  static void @@ -1158,6 +1160,8 @@ irc_handle_cap_list (struct client *c, struct irc_cap_args *a)  		str_vector_add (&caps, "multi-prefix");  	if (c->caps_enabled & IRC_CAP_INVITE_NOTIFY)  		str_vector_add (&caps, "invite-notify"); +	if (c->caps_enabled & IRC_CAP_ECHO_MESSAGE) +		str_vector_add (&caps, "echo-message");  	char *caps_str = join_str_vector (&caps, ' ');  	str_vector_free (&caps); @@ -1172,6 +1176,8 @@ irc_decode_capability (const char *name)  		return IRC_CAP_MULTI_PREFIX;  	if (!strcmp (name, "invite-notify"))  		return IRC_CAP_INVITE_NOTIFY; +	if (!strcmp (name, "echo-message")) +		return IRC_CAP_ECHO_MESSAGE;  	return 0;  } @@ -1969,6 +1975,11 @@ irc_handle_user_message (const struct irc_message *msg, struct client *c,  			c->nickname, c->username, c->hostname, command, target, text);  		if (allow_away_reply && client->away_message)  			irc_send_reply (c, IRC_RPL_AWAY, target, client->away_message); + +		// Acknowledging a message from the client to itself would be silly +		if (client != c && (c->caps_enabled & IRC_CAP_ECHO_MESSAGE)) +			client_send (c, ":%s!%s@%s %s %s :%s", +				c->nickname, c->username, c->hostname, command, target, text);  		return;  	} @@ -1987,7 +1998,8 @@ irc_handle_user_message (const struct irc_message *msg, struct client *c,  		char *message = xstrdup_printf (":%s!%s@%s %s %s :%s",  			c->nickname, c->username, c->hostname, command, target, text); -		irc_channel_multicast (chan, message, c); +		irc_channel_multicast (chan, message, +			(c->caps_enabled & IRC_CAP_ECHO_MESSAGE) ? NULL : c);  		free (message);  		return;  	} | 
