/** * drop.C: This file contains code for the ChanServ DROP function. * * 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: drop.C,v 1.8 2007/09/22 14:27:27 pippijn Exp $ */ #include "atheme.h" #include #include #include static char const rcsid[] = "$Id: drop.C,v 1.8 2007/09/22 14:27:27 pippijn Exp $"; REGISTER_MODULE ("chanserv/drop", false, "The Ermyth Team "); static void cs_cmd_drop (sourceinfo_t *si, int parc, char *parv[]); command_t const cs_drop = { "DROP", N_("Drops a channel registration."), AC_NONE, 1, cs_cmd_drop }; E cmdvec cs_cmdtree; E helpvec cs_helptree; bool _modinit (module *m) { cs_cmdtree << cs_drop; help_addentry (cs_helptree, "DROP", "help/chanserv/drop", NULL); return true; } void _moddeinit () { cs_cmdtree >> cs_drop; help_delentry (cs_helptree, "DROP"); } static void cs_cmd_drop (sourceinfo_t *si, int parc, char *parv[]) { mychan_t *mc; char *name = parv[0]; if (!name) { command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "DROP"); command_fail (si, fault::needmoreparams, _("Syntax: DROP <#channel>")); return; } if (*name != '#') { command_fail (si, fault::badparams, STR_INVALID_PARAMS, "DROP"); command_fail (si, fault::badparams, _("Syntax: DROP <#channel>")); return; } if (!(mc = mychan_t::find (name))) { command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), name); return; } if (si->c != NULL) { command_fail (si, fault::noprivs, _("For security reasons, you may not drop a channel registration with a fantasy command.")); return; } if (!si->smu->is_founder (mc) && !has_priv (si, PRIV_CHAN_ADMIN)) { command_fail (si, fault::noprivs, _("You are not authorized to perform this operation.")); return; } if (mc->find_metadata ("private:close:closer") && !has_priv (si, PRIV_CHAN_ADMIN)) { logcommand (si, CMDLOG_REGISTER, "%s failed DROP (closed)", mc->name); command_fail (si, fault::noprivs, _("The channel \2%s\2 is closed; it cannot be dropped."), mc->name); return; } if (mc->flags & MC_HOLD) { command_fail (si, fault::noprivs, _("The channel \2%s\2 is held; it cannot be dropped."), mc->name); return; } if (!si->smu->is_founder (mc)) { logcommand (si, CMDLOG_ADMIN | LG_REGISTER, "%s DROP", mc->name); wallops ("%s dropped the channel \2%s\2", get_oper_name (si), name); } else logcommand (si, CMDLOG_REGISTER, "%s DROP", mc->name); snoop ("DROP: \2%s\2 by \2%s\2 as \2%s\2", mc->name, get_oper_name (si), si->smu->name); mc->callback.drop (mc); if ((config_options.chan && irccasecmp (mc->name, config_options.chan)) || !config_options.chan) part (mc->name, chansvs.nick); mc->refcnt_dec (); command_success_nodata (si, _("The channel \2%s\2 has been dropped."), name); return; }