mirror of
https://github.com/matrix-construct/construct
synced 2024-08-24 10:34:43 +02:00
Add client to ircd::client:: namespace. Also move former struct User and struct Server into client.cc as opaque structure demo.
56 lines
1.2 KiB
C++
56 lines
1.2 KiB
C++
/*
|
|
* Channel extban type: matches users who are in a certain public channel
|
|
* -- jilles
|
|
*/
|
|
|
|
namespace mode = ircd::chan::mode;
|
|
namespace ext = mode::ext;
|
|
using namespace ircd;
|
|
|
|
static const char extb_desc[] = "Channel ($c) extban type";
|
|
|
|
static int _modinit(void);
|
|
static void _moddeinit(void);
|
|
static int eb_channel(const char *data, client::client *client_p, chan::chan *chptr, mode::type type);
|
|
|
|
DECLARE_MODULE_AV2(extb_channel, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, extb_desc);
|
|
|
|
static int
|
|
_modinit(void)
|
|
{
|
|
ext::table['c'] = eb_channel;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void
|
|
_moddeinit(void)
|
|
{
|
|
ext::table['c'] = NULL;
|
|
}
|
|
|
|
static int eb_channel(const char *data, client::client *client_p,
|
|
chan::chan *chptr, mode::type type)
|
|
{
|
|
using namespace ext;
|
|
|
|
chan::chan *chptr2;
|
|
|
|
(void)chptr;
|
|
|
|
if (data == NULL)
|
|
return INVALID;
|
|
|
|
chptr2 = chan::get(data, std::nothrow);
|
|
if (chptr2 == NULL)
|
|
return INVALID;
|
|
/* require consistent target */
|
|
if (chptr->name[0] == '#' && data[0] == '&')
|
|
return INVALID;
|
|
/* privacy! don't allow +s/+p channels to influence another channel */
|
|
if (!is_public(chptr2) && chptr2 != chptr)
|
|
return INVALID;
|
|
|
|
return is_member(chptr2, client_p)? MATCH : NOMATCH;
|
|
}
|