| 1 |
/* |
| 2 |
* Copyright (c) 2005 William Pitcock, et al. |
| 3 |
* Rights to this code are as documented in doc/LICENSE. |
| 4 |
* |
| 5 |
* This file contains code for the CService KICK functions. |
| 6 |
* |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "atheme.h" |
| 10 |
|
| 11 |
DECLARE_MODULE_V1 |
| 12 |
( |
| 13 |
"chanserv/clear_bans", false, _modinit, _moddeinit, |
| 14 |
PACKAGE_STRING, |
| 15 |
VENDOR_STRING |
| 16 |
); |
| 17 |
|
| 18 |
static void cs_cmd_clear_bans(sourceinfo_t *si, int parc, char *parv[]); |
| 19 |
|
| 20 |
command_t cs_clear_bans = { "BANS", N_("Clears bans or other lists of a channel."), |
| 21 |
AC_NONE, 2, cs_cmd_clear_bans, { .path = "cservice/clear_bans" } }; |
| 22 |
|
| 23 |
mowgli_patricia_t **cs_clear_cmds; |
| 24 |
|
| 25 |
void _modinit(module_t *m) |
| 26 |
{ |
| 27 |
MODULE_TRY_REQUEST_SYMBOL(m, cs_clear_cmds, "chanserv/clear", "cs_clear_cmds"); |
| 28 |
|
| 29 |
command_add(&cs_clear_bans, *cs_clear_cmds); |
| 30 |
} |
| 31 |
|
| 32 |
void _moddeinit(module_unload_intent_t intent) |
| 33 |
{ |
| 34 |
command_delete(&cs_clear_bans, *cs_clear_cmds); |
| 35 |
} |
| 36 |
|
| 37 |
static void cs_cmd_clear_bans(sourceinfo_t *si, int parc, char *parv[]) |
| 38 |
{ |
| 39 |
channel_t *c; |
| 40 |
mychan_t *mc = mychan_find(parv[0]); |
| 41 |
chanban_t *cb; |
| 42 |
mowgli_node_t *n, *tn; |
| 43 |
const char *item = parv[1], *p; |
| 44 |
int hits; |
| 45 |
|
| 46 |
if (item == NULL) |
| 47 |
item = "b"; |
| 48 |
if (*item == '+' || *item == '-') |
| 49 |
item++; |
| 50 |
if (!strcmp(item, "*")) |
| 51 |
item = ircd->ban_like_modes; |
| 52 |
for (p = item; *p != '\0'; p++) |
| 53 |
{ |
| 54 |
if (!strchr(ircd->ban_like_modes, *p)) |
| 55 |
{ |
| 56 |
command_fail(si, fault_badparams, _("Invalid mode; valid ones are %s."), ircd->ban_like_modes); |
| 57 |
return; |
| 58 |
} |
| 59 |
} |
| 60 |
if (*item == '\0') |
| 61 |
{ |
| 62 |
command_fail(si, fault_badparams, _("Invalid mode; valid ones are %s."), ircd->ban_like_modes); |
| 63 |
return; |
| 64 |
} |
| 65 |
|
| 66 |
if (!mc) |
| 67 |
{ |
| 68 |
command_fail(si, fault_nosuch_target, _("Channel \2%s\2 is not registered."), parv[0]); |
| 69 |
return; |
| 70 |
} |
| 71 |
|
| 72 |
if (!(c = channel_find(parv[0]))) |
| 73 |
{ |
| 74 |
command_fail(si, fault_nosuch_target, _("\2%s\2 is currently empty."), parv[0]); |
| 75 |
return; |
| 76 |
} |
| 77 |
|
| 78 |
if (!chanacs_source_has_flag(mc, si, CA_RECOVER)) |
| 79 |
{ |
| 80 |
command_fail(si, fault_noprivs, _("You are not authorized to perform this operation.")); |
| 81 |
return; |
| 82 |
} |
| 83 |
|
| 84 |
if (metadata_find(mc, "private:close:closer")) |
| 85 |
{ |
| 86 |
command_fail(si, fault_noprivs, _("\2%s\2 is closed."), parv[0]); |
| 87 |
return; |
| 88 |
} |
| 89 |
|
| 90 |
hits = 0; |
| 91 |
MOWGLI_ITER_FOREACH_SAFE(n, tn, c->bans.head) |
| 92 |
{ |
| 93 |
cb = n->data; |
| 94 |
if (!strchr(item, cb->type)) |
| 95 |
continue; |
| 96 |
modestack_mode_param(chansvs.nick, c, MTYPE_DEL, cb->type, cb->mask); |
| 97 |
chanban_delete(cb); |
| 98 |
hits++; |
| 99 |
} |
| 100 |
|
| 101 |
if (hits > 4) |
| 102 |
command_add_flood(si, FLOOD_MODERATE); |
| 103 |
|
| 104 |
logcommand(si, CMDLOG_DO, "CLEAR:BANS: \2%s\2 on \2%s\2", |
| 105 |
item, mc->name); |
| 106 |
|
| 107 |
command_success_nodata(si, _("Cleared %s modes on \2%s\2 (%d removed)."), |
| 108 |
item, parv[0], hits); |
| 109 |
} |
| 110 |
|
| 111 |
/* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs |
| 112 |
* vim:ts=8 |
| 113 |
* vim:sw=8 |
| 114 |
* vim:noexpandtab |
| 115 |
*/ |