diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-06-13 12:13:43 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-06-13 12:13:43 +0200 |
commit | 5c5be1af071f009ac4142d5e975e66a953d5efe6 (patch) | |
tree | 05eba3c73c26d15cb9161210ed9a735f740f8a6c /kike.c | |
parent | dd17a2944585a33421f0d0f75ef5cf2d3e7bb046 (diff) | |
download | xK-5c5be1af071f009ac4142d5e975e66a953d5efe6.tar.gz xK-5c5be1af071f009ac4142d5e975e66a953d5efe6.tar.xz xK-5c5be1af071f009ac4142d5e975e66a953d5efe6.zip |
kike: implement CAP echo-message
Diffstat (limited to 'kike.c')
-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; } |