]> jfr.im git - solanum.git/blame - extensions/extb_channel.c
modules: Add AV2 descriptions to all m_u* modules
[solanum.git] / extensions / extb_channel.c
CommitLineData
212380e3
AC
1/*
2 * Channel extban type: matches users who are in a certain public channel
3 * -- jilles
212380e3
AC
4 */
5
6#include "stdinc.h"
7#include "modules.h"
8#include "client.h"
9#include "channel.h"
10#include "hash.h"
11#include "ircd.h"
12
13static int _modinit(void);
14static void _moddeinit(void);
15static int eb_channel(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type);
c81afd15 16static const char extb_desc[] = "Channel ($c) extban type";
212380e3 17
c81afd15 18DECLARE_MODULE_AV2(extb_channel, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, extb_desc);
212380e3
AC
19
20static int
21_modinit(void)
22{
23 extban_table['c'] = eb_channel;
24
25 return 0;
26}
27
28static void
29_moddeinit(void)
30{
31 extban_table['c'] = NULL;
32}
33
34static int eb_channel(const char *data, struct Client *client_p,
35 struct Channel *chptr, long mode_type)
36{
37 struct Channel *chptr2;
38
39 (void)chptr;
40 (void)mode_type;
41 if (data == NULL)
42 return EXTBAN_INVALID;
43 chptr2 = find_channel(data);
44 if (chptr2 == NULL)
45 return EXTBAN_INVALID;
46 /* require consistent target */
47 if (chptr->chname[0] == '#' && data[0] == '&')
48 return EXTBAN_INVALID;
49 /* privacy! don't allow +s/+p channels to influence another channel */
3bfac098 50 if (!PubChannel(chptr2) && chptr2 != chptr)
212380e3
AC
51 return EXTBAN_INVALID;
52 return IsMember(client_p, chptr2) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
53}