From a60fc4d47f827a4989799e88a6aaf7db1cc5a44c Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Sat, 13 Jun 2015 12:17:56 +0200 Subject: kike: implement CAP userhost-in-names --- kike.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/kike.c b/kike.c index 2909b5f..3a80b5d 100644 --- a/kike.c +++ b/kike.c @@ -297,7 +297,8 @@ enum { IRC_CAP_MULTI_PREFIX = (1 << 0), IRC_CAP_INVITE_NOTIFY = (1 << 1), - IRC_CAP_ECHO_MESSAGE = (1 << 2) + IRC_CAP_ECHO_MESSAGE = (1 << 2), + IRC_CAP_USERHOST_IN_NAMES = (1 << 3) }; struct client @@ -1146,8 +1147,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 echo-message", - a->target); + client_send (c, "CAP %s LS :multi-prefix invite-notify echo-message" + " userhost-in-names", a->target); } static void @@ -1162,6 +1163,8 @@ irc_handle_cap_list (struct client *c, struct irc_cap_args *a) str_vector_add (&caps, "invite-notify"); if (c->caps_enabled & IRC_CAP_ECHO_MESSAGE) str_vector_add (&caps, "echo-message"); + if (c->caps_enabled & IRC_CAP_USERHOST_IN_NAMES) + str_vector_add (&caps, "userhost-in-names"); char *caps_str = join_str_vector (&caps, ' '); str_vector_free (&caps); @@ -1178,6 +1181,8 @@ irc_decode_capability (const char *name) return IRC_CAP_INVITE_NOTIFY; if (!strcmp (name, "echo-message")) return IRC_CAP_ECHO_MESSAGE; + if (!strcmp (name, "userhost-in-names")) + return IRC_CAP_USERHOST_IN_NAMES; return 0; } @@ -2105,6 +2110,9 @@ irc_send_rpl_namreply (struct client *c, const struct channel *chan) str_init (&result); irc_append_prefixes (c, iter, &result); str_append (&result, iter->c->nickname); + if (c->caps_enabled & IRC_CAP_USERHOST_IN_NAMES) + str_append_printf (&result, + "!%s@%s", iter->c->username, iter->c->hostname); str_vector_add_owned (&nicks, str_steal (&result)); } -- cgit v1.2.3-70-g09d2