kike: implement CAP userhost-in-names

This commit is contained in:
Přemysl Eric Janouch 2015-06-13 12:17:56 +02:00
parent 5c5be1af07
commit a60fc4d47f
1 changed files with 11 additions and 3 deletions

14
kike.c
View File

@ -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));
}