]> jfr.im git - solanum.git/blob - extensions/extb_oper.c
m_shedding: user shedding module based on oftc-hybrid
[solanum.git] / extensions / extb_oper.c
1 /*
2 * Oper extban type: matches opers
3 * -- jilles
4 */
5
6 #include "stdinc.h"
7 #include "modules.h"
8 #include "client.h"
9 #include "privilege.h"
10 #include "s_newconf.h"
11 #include "ircd.h"
12
13 static const char extb_desc[] = "Oper ($o) extban type";
14
15 static int _modinit(void);
16 static void _moddeinit(void);
17 static int eb_oper(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type);
18
19 DECLARE_MODULE_AV2(extb_oper, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, extb_desc);
20
21 static int
22 _modinit(void)
23 {
24 extban_table['o'] = eb_oper;
25
26 return 0;
27 }
28
29 static void
30 _moddeinit(void)
31 {
32 extban_table['o'] = NULL;
33 }
34
35 static int eb_oper(const char *data, struct Client *client_p,
36 struct Channel *chptr, long mode_type)
37 {
38
39 (void)chptr;
40 (void)mode_type;
41
42 if (data != NULL)
43 {
44 struct PrivilegeSet *set = privilegeset_get(data);
45 if (set != NULL && client_p->user->privset == set)
46 return EXTBAN_MATCH;
47
48 /* $o:admin or whatever */
49 return HasPrivilege(client_p, data) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
50 }
51
52 return IsOper(client_p) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
53 }