9 static const char inv_notify_desc
[] = "Notifies channel on /invite and provides the invite-notify client capability";
11 static void hook_invite(void *);
12 static void m_invited(struct MsgBuf
*, struct Client
*, struct Client
*, int, const char **);
13 static unsigned int CAP_INVITE_NOTIFY
;
15 mapi_hfn_list_av1 inv_notify_hfnlist
[] = {
16 { "invite", hook_invite
, HOOK_MONITOR
},
20 struct Message invited_msgtab
= {
21 "INVITED", 0, 0, 0, 0,
22 {mg_ignore
, mg_ignore
, mg_ignore
, mg_ignore
, {m_invited
, 4}, mg_ignore
}
25 mapi_cap_list_av2 inv_notify_caplist
[] = {
26 { MAPI_CAP_CLIENT
, "invite-notify", NULL
, &CAP_INVITE_NOTIFY
},
27 { 0, NULL
, NULL
, NULL
}
30 mapi_clist_av1 inv_notify_clist
[] = { &invited_msgtab
, NULL
};
33 invite_notify(struct Client
*source
, struct Client
*target
, struct Channel
*channel
)
35 sendto_channel_local_with_capability(source
, CHFL_CHANOP
, 0, CAP_INVITE_NOTIFY
, channel
,
36 ":%s NOTICE %s :%s is inviting %s to %s.",
37 me
.name
, channel
->chname
, source
->name
, target
->name
, channel
->chname
);
38 sendto_channel_local_with_capability(source
, CHFL_CHANOP
, CAP_INVITE_NOTIFY
, 0, channel
,
39 ":%s!%s@%s INVITE %s %s", source
->name
, source
->username
,
40 source
->host
, target
->name
, channel
->chname
);
44 hook_invite(void *data_
)
46 hook_data_channel_approval
*data
= data_
;
49 /* Don't notify if another hook is rejecting the invite.
50 * This won't work if the other hook is after us... but really, it's
51 * the thought that counts.
55 sendto_server(NULL
, NULL
, CAP_TS6
| CAP_ENCAP
, 0, "ENCAP * INVITED %s %s %s",
56 use_id(data
->client
), use_id(data
->target
),
58 invite_notify(data
->client
, data
->target
, data
->chptr
);
62 m_invited(struct MsgBuf
*msgbuf
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char **parv
)
64 struct Client
*inviter
= find_person(parv
[1]);
65 struct Client
*target
= find_person(parv
[2]);
66 struct Channel
*chptr
= find_channel(parv
[3]);
68 if (inviter
== NULL
|| target
== NULL
|| chptr
== NULL
)
71 invite_notify(inviter
, target
, chptr
);
74 DECLARE_MODULE_AV2("invite_notify", NULL
, NULL
, inv_notify_clist
, NULL
, inv_notify_hfnlist
, inv_notify_caplist
, NULL
, inv_notify_desc
);