/** * clear_bans.C: This file contains code for the ChanServ CLEAR BANS functions. * * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team * Rights to this code are as documented in COPYING. * * * Portions of this file were derived from sources bearing the following license: * Copyright © 2005 William Pitcock, et al. * Rights to this code are as documented in doc/pod/license.pod. * * $Id: clear_bans.C,v 1.8 2007/09/22 14:27:27 pippijn Exp $ */ #include "atheme.h" #include #include #include static char const rcsid[] = "$Id: clear_bans.C,v 1.8 2007/09/22 14:27:27 pippijn Exp $"; REGISTER_MODULE ("chanserv/clear_bans", false, "The Ermyth Team "); static void cs_cmd_clear_bans (sourceinfo_t *si, int parc, char *parv[]); command_t const cs_clear_bans = { "BANS", N_("Clears bans or other lists of a channel."), AC_NONE, 2, cs_cmd_clear_bans }; E cmdvec cs_clear_cmds; E helpvec cs_helptree; bool _modinit (module *m) { cs_clear_cmds << cs_clear_bans; help_addentry (cs_helptree, "CLEAR BANS", "help/chanserv/clear_bans", NULL); return true; } void _moddeinit () { cs_clear_cmds >> cs_clear_bans; help_delentry (cs_helptree, "CLEAR BANS"); } static void cs_cmd_clear_bans (sourceinfo_t *si, int parc, char *parv[]) { channel_t *c; mychan_t *mc = mychan_t::find (parv[0]); chanban_t *cb; node_t *n, *tn; char const *item = parv[1], *p; int hits; if (item == NULL) item = "b"; if (*item == '+' || *item == '-') item++; if (!strcmp (item, "*")) item = ircd->ban_like_modes; for (p = item; *p != '\0'; p++) { if (!strchr (ircd->ban_like_modes, *p)) { command_fail (si, fault::badparams, _("Invalid mode; valid ones are %s."), ircd->ban_like_modes); return; } } if (*item == '\0') { command_fail (si, fault::badparams, _("Invalid mode; valid ones are %s."), ircd->ban_like_modes); return; } if (!mc) { command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), parv[0]); return; } if (!(c = channel_find (parv[0]))) { command_fail (si, fault::nosuch_target, _("\2%s\2 is currently empty."), parv[0]); return; } if (!chanacs_source_has_flag (mc, si, CA_RECOVER)) { command_fail (si, fault::noprivs, _("You are not authorized to perform this operation.")); return; } if (mc->find_metadata ("private:close:closer")) { command_fail (si, fault::noprivs, _("\2%s\2 is closed."), parv[0]); return; } hits = 0; LIST_FOREACH_SAFE (n, tn, c->bans.head) { cb = static_cast (n->data); if (!strchr (item, cb->type)) continue; modestack_mode_param (chansvs.nick, c, MTYPE_DEL, cb->type, cb->mask); chanban_delete (cb); hits++; } logcommand (si, CMDLOG_DO, "%s CLEAR BANS %s", mc->name, item); command_success_nodata (si, _("Cleared %s modes on \2%s\2 (%d removed)."), item, parv[0], hits); }