2007-01-25 07:40:21 +01:00
|
|
|
/*
|
|
|
|
* Canjoin extban type: matches users who are or are not banned from a
|
|
|
|
* specified channel.
|
|
|
|
* -- nenolod/jilles
|
|
|
|
*/
|
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
namespace mode = ircd::chan::mode;
|
2016-08-17 05:01:20 +02:00
|
|
|
namespace ext = mode::ext;
|
2016-08-13 05:05:54 +02:00
|
|
|
using namespace ircd;
|
|
|
|
|
2016-03-09 08:29:41 +01:00
|
|
|
static const char extb_desc[] = "Can join ($j) extban type - matches users who are or are not banned from a specified channel";
|
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
static int _modinit(void);
|
|
|
|
static void _moddeinit(void);
|
2016-08-22 03:57:43 +02:00
|
|
|
static int eb_canjoin(const char *data, client::client *client_p, chan::chan *chptr, mode::type type);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-03-07 07:31:41 +01:00
|
|
|
DECLARE_MODULE_AV2(extb_canjoin, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, extb_desc);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
static int
|
|
|
|
_modinit(void)
|
|
|
|
{
|
2016-08-17 05:01:20 +02:00
|
|
|
ext::table['j'] = eb_canjoin;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_moddeinit(void)
|
|
|
|
{
|
2016-08-17 05:01:20 +02:00
|
|
|
ext::table['j'] = NULL;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
static int
|
2016-08-22 03:57:43 +02:00
|
|
|
eb_canjoin(const char *data, client::client *client_p, chan::chan *chptr, mode::type type)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-17 05:01:20 +02:00
|
|
|
using namespace ext;
|
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
chan::chan *chptr2;
|
2007-01-25 07:40:21 +01:00
|
|
|
int ret;
|
|
|
|
static int recurse = 0;
|
|
|
|
|
|
|
|
/* don't process a $j in a $j'ed list */
|
|
|
|
if (recurse)
|
2016-08-17 05:01:20 +02:00
|
|
|
return INVALID;
|
2007-01-25 07:40:21 +01:00
|
|
|
if (data == NULL)
|
2016-08-17 05:01:20 +02:00
|
|
|
return INVALID;
|
2016-08-20 04:51:37 +02:00
|
|
|
chptr2 = chan::get(data, std::nothrow);
|
2007-01-25 07:40:21 +01:00
|
|
|
/* must exist, and no point doing this with the same channel */
|
|
|
|
if (chptr2 == NULL || chptr2 == chptr)
|
2016-08-17 05:01:20 +02:00
|
|
|
return INVALID;
|
2007-01-25 07:40:21 +01:00
|
|
|
/* require consistent target */
|
2016-08-18 07:33:38 +02:00
|
|
|
if (chptr->name[0] == '#' && data[0] == '&')
|
2016-08-17 05:01:20 +02:00
|
|
|
return INVALID;
|
2007-01-25 07:40:21 +01:00
|
|
|
/* this allows getting some information about ban exceptions
|
|
|
|
* but +s/+p doesn't seem the right criterion */
|
|
|
|
#if 0
|
|
|
|
/* privacy! don't allow +s/+p channels to influence another channel */
|
|
|
|
if (!PubChannel(chptr2))
|
2016-08-17 05:01:20 +02:00
|
|
|
return INVALID;
|
2007-01-25 07:40:21 +01:00
|
|
|
#endif
|
|
|
|
recurse = 1;
|
2016-08-19 07:58:17 +02:00
|
|
|
ret = check(*chptr2, mode::BAN, *client_p)? MATCH : NOMATCH;
|
2007-01-25 07:40:21 +01:00
|
|
|
recurse = 0;
|
|
|
|
return ret;
|
|
|
|
}
|