aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-06-13 12:17:56 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-06-13 12:17:56 +0200
commita60fc4d47f827a4989799e88a6aaf7db1cc5a44c (patch)
tree1c62e1bbfa27fdb637044848463116f6dc099e92
parent5c5be1af071f009ac4142d5e975e66a953d5efe6 (diff)
downloadxK-a60fc4d47f827a4989799e88a6aaf7db1cc5a44c.tar.gz
xK-a60fc4d47f827a4989799e88a6aaf7db1cc5a44c.tar.xz
xK-a60fc4d47f827a4989799e88a6aaf7db1cc5a44c.zip
kike: implement CAP userhost-in-names
-rw-r--r--kike.c14
1 files 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));
}