/** * register.C: This file contains code for the ChanServ REGISTER 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: register.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: register.C,v 1.9 2007/09/22 14:27:27 pippijn Exp $"; REGISTER_MODULE ("chanserv/register", false, "The Ermyth Team "); static void cs_cmd_register (sourceinfo_t *si, int parc, char *parv[]); command_t const cs_register = { "REGISTER", N_("Registers a channel."), AC_NONE, 3, cs_cmd_register }; E cmdvec cs_cmdtree; E helpvec cs_helptree; bool _modinit (module *m) { cs_cmdtree << cs_register; help_addentry (cs_helptree, "REGISTER", "help/chanserv/register", NULL); return true; } void _moddeinit () { cs_cmdtree >> cs_register; help_delentry (cs_helptree, "REGISTER"); } static void cs_cmd_register (sourceinfo_t *si, int parc, char *parv[]) { channel_t *c; chanuser_t *cu; mychan_t *mc; char *name = parv[0]; char str[21]; if (!name) { command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "REGISTER"); command_fail (si, fault::needmoreparams, _("To register a channel: REGISTER <#channel>")); return; } if (*name != '#') { command_fail (si, fault::badparams, STR_INVALID_PARAMS, "REGISTER"); command_fail (si, fault::badparams, _("Syntax: REGISTER <#channel>")); return; } /* make sure they're logged in */ if (!si->smu) { command_fail (si, fault::noprivs, _("You are not logged in.")); return; } if (si->smu->flags & MU_WAITAUTH) { command_fail (si, fault::notverified, _("You need to verify your email address before you may register channels.")); return; } /* make sure it isn't already registered */ if ((mc = mychan_t::find (name))) { command_fail (si, fault::alreadyexists, _("\2%s\2 is already registered to \2%s\2."), mc->name, mc->founder_names ()); return; } /* make sure the channel exists */ if (!(c = channel_find (name))) { command_fail (si, fault::nosuch_target, _("The channel \2%s\2 must exist in order to register it."), name); return; } /* make sure they're in it */ if (!(cu = chanuser_find (c, si->su))) { command_fail (si, fault::noprivs, _("You must be in \2%s\2 in order to register it."), name); return; } /* make sure they're opped */ if (!(CMODE_OP & cu->modes)) { command_fail (si, fault::noprivs, _("You must be a channel operator in \2%s\2 in order to register it."), name); return; } if ((si->smu->num_channels () >= me.maxchans) && !has_priv (si, PRIV_REG_NOLIMIT)) { command_fail (si, fault::toomany, _("You have too many channels registered.")); return; } logcommand (si, CMDLOG_REGISTER, "%s REGISTER", name); snoop ("REGISTER: \2%s\2 to \2%s\2 as \2%s\2", name, get_oper_name (si), si->smu->name); mc = mychan_t::create (name); mc->registered = NOW; mc->used = NOW; mc->mlock_on |= (CMODE_NOEXT | CMODE_TOPIC); if (c->limit == 0) mc->mlock_off |= CMODE_LIMIT; if (c->key == NULL) mc->mlock_off |= CMODE_KEY; mc->flags |= config_options.defcflags; chanacs_add (mc, si->smu, CA_INITIAL & ca_all, NOW); if (c->ts > 0) { snprintf (str, sizeof str, "%lu", (unsigned long) c->ts); mc->add_metadata ("private:channelts", str); } command_success_nodata (si, _("\2%s\2 is now registered to \2%s\2."), mc->name, si->smu->name); mc->callback.registered (mc, si); }