/** * ftransfer.C: This file contains code for the ChanServ FTRANSFER 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: ftransfer.C,v 1.9 2007/09/22 14:27:27 pippijn Exp $ */ #include "atheme.h" #include #include #include #include #include static char const rcsid[] = "$Id: ftransfer.C,v 1.9 2007/09/22 14:27:27 pippijn Exp $"; REGISTER_MODULE ("chanserv/ftransfer", false, "The Ermyth Team "); static void cs_cmd_ftransfer (sourceinfo_t *si, int parc, char *parv[]); command_t const cs_ftransfer = { "FTRANSFER", N_("Forces foundership transfer of a channel."), PRIV_CHAN_ADMIN, 2, cs_cmd_ftransfer }; E cmdvec cs_cmdtree; E helpvec cs_helptree; static void cs_cmd_ftransfer (sourceinfo_t *si, int parc, char *parv[]) { myuser_t *tmu; mychan_t *mc; node_t *n; chanacs_t *ca; char *name = parv[0]; char *newfndr = parv[1]; char const *oldfndr; if (!name || !newfndr) { command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "FTRANSFER"); command_fail (si, fault::needmoreparams, _("Syntax: FTRANSFER <#channel> ")); return; } if (!(tmu = myuser_t::find_ext (newfndr))) { command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), newfndr); return; } if (!(mc = mychan_t::find (name))) { command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), name); return; } oldfndr = mc->founder_names (); if (!strcmp (tmu->name, oldfndr)) { command_fail (si, fault::nochange, _("\2%s\2 is already the founder of \2%s\2."), tmu->name, name); return; } /* no maxchans check (intentional -- this is an oper command) */ snoop ("FTRANSFER: %s transferred %s from %s to %s", get_oper_name (si), name, oldfndr, tmu->name); wallops ("%s transferred foundership of %s from %s to %s", get_oper_name (si), name, oldfndr, tmu->name); logcommand (si, CMDLOG_ADMIN | LG_REGISTER, "%s FTRANSFER from %s to %s", mc->name, oldfndr, tmu->name); verbose (mc, "Foundership transfer from \2%s\2 to \2%s\2 forced by %s administration.", oldfndr, tmu->name, me.netname); command_success_nodata (si, _("Foundership of \2%s\2 has been transferred from \2%s\2 to \2%s\2."), name, oldfndr, tmu->name); LIST_FOREACH(n, mc->chanacs.head) { ca = static_cast (n->data); /* CA_FLAGS is always on if CA_FOUNDER is on, this just * ensures we don't crash if not -- jilles */ if (ca->myuser != NULL && ca->level & CA_FOUNDER) chanacs_modify_simple(ca, CA_FLAGS, CA_FOUNDER); } mc->used = NOW; chanacs_change_simple (mc, tmu, NULL, CA_FOUNDER_0, 0); /* delete transfer metadata -- prevents a user from stealing it back */ mc->del_metadata ("private:verify:founderchg:newfounder"); mc->del_metadata ("private:verify:founderchg:timestamp"); } bool _modinit (module *m) { cs_cmdtree << cs_ftransfer; help_addentry (cs_helptree, "FTRANSFER", "help/chanserv/ftransfer", NULL); return true; } void _moddeinit () { cs_cmdtree >> cs_ftransfer; help_delentry (cs_helptree, "FTRANSFER"); }