kike: implement CAP invite-notify
This commit is contained in:
parent
1d53b87016
commit
dd17a29445
22
kike.c
22
kike.c
|
@ -296,6 +296,7 @@ enum
|
|||
enum
|
||||
{
|
||||
IRC_CAP_MULTI_PREFIX = (1 << 0),
|
||||
IRC_CAP_INVITE_NOTIFY = (1 << 1)
|
||||
};
|
||||
|
||||
struct client
|
||||
|
@ -1144,7 +1145,7 @@ 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", a->target);
|
||||
client_send (c, "CAP %s LS :multi-prefix invite-notify", a->target);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1155,6 +1156,8 @@ irc_handle_cap_list (struct client *c, struct irc_cap_args *a)
|
|||
|
||||
if (c->caps_enabled & IRC_CAP_MULTI_PREFIX)
|
||||
str_vector_add (&caps, "multi-prefix");
|
||||
if (c->caps_enabled & IRC_CAP_INVITE_NOTIFY)
|
||||
str_vector_add (&caps, "invite-notify");
|
||||
|
||||
char *caps_str = join_str_vector (&caps, ' ');
|
||||
str_vector_free (&caps);
|
||||
|
@ -1167,6 +1170,8 @@ irc_decode_capability (const char *name)
|
|||
{
|
||||
if (!strcmp (name, "multi-prefix"))
|
||||
return IRC_CAP_MULTI_PREFIX;
|
||||
if (!strcmp (name, "invite-notify"))
|
||||
return IRC_CAP_INVITE_NOTIFY;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2481,6 +2486,17 @@ irc_handle_kick (const struct irc_message *msg, struct client *c)
|
|||
str_vector_free (&users);
|
||||
}
|
||||
|
||||
static void
|
||||
irc_send_invite_notifications
|
||||
(struct channel *chan, struct client *c, struct client *target)
|
||||
{
|
||||
for (struct channel_user *iter = chan->users; iter; iter = iter->next)
|
||||
if (iter->c != target && iter->c->caps_enabled & IRC_CAP_INVITE_NOTIFY)
|
||||
client_send (iter->c, ":%s!%s@%s INVITE %s %s",
|
||||
c->nickname, c->username, c->hostname,
|
||||
target->nickname, chan->name);
|
||||
}
|
||||
|
||||
static void
|
||||
irc_handle_invite (const struct irc_message *msg, struct client *c)
|
||||
{
|
||||
|
@ -2507,6 +2523,10 @@ irc_handle_invite (const struct irc_message *msg, struct client *c)
|
|||
str_map_set (&client->invites, channel_name, (void *) 1);
|
||||
else if ((chan->modes & IRC_CHAN_MODE_INVITE_ONLY))
|
||||
RETURN_WITH_REPLY (c, IRC_ERR_CHANOPRIVSNEEDED, channel_name);
|
||||
|
||||
// It's not specified when and how we should send out invite-notify
|
||||
if (chan->modes & IRC_CHAN_MODE_INVITE_ONLY)
|
||||
irc_send_invite_notifications (chan, c, client);
|
||||
}
|
||||
|
||||
client_send (client, ":%s!%s@%s INVITE %s %s",
|
||||
|
|
Loading…
Reference in New Issue