aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-06-13 12:02:17 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-06-13 12:02:17 +0200
commitdd17a2944585a33421f0d0f75ef5cf2d3e7bb046 (patch)
treec1aeef094b53ca54fb0456e3499f36375be58c08
parent1d53b87016965bb9d4fbb895713c6ba25fc4241e (diff)
downloadxK-dd17a2944585a33421f0d0f75ef5cf2d3e7bb046.tar.gz
xK-dd17a2944585a33421f0d0f75ef5cf2d3e7bb046.tar.xz
xK-dd17a2944585a33421f0d0f75ef5cf2d3e7bb046.zip
kike: implement CAP invite-notify
-rw-r--r--kike.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/kike.c b/kike.c
index 83aa659..824566a 100644
--- a/kike.c
+++ b/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;
}
@@ -2482,6 +2487,17 @@ irc_handle_kick (const struct irc_message *msg, struct client *c)
}
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)
{
if (msg->params.len < 2)
@@ -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",