/** * invite.C: This file contains code for the ChanServ INVITE 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: invite.C,v 1.8 2007/09/22 14:27:27 pippijn Exp $ */ #include "atheme.h" #include #include #include static char const rcsid[] = "$Id: invite.C,v 1.8 2007/09/22 14:27:27 pippijn Exp $"; REGISTER_MODULE ("chanserv/invite", false, "The Ermyth Team "); static void cs_cmd_invite (sourceinfo_t *si, int parc, char *parv[]); command_t const cs_invite = { "INVITE", N_("Invites you to a channel."), AC_NONE, 1, cs_cmd_invite }; E cmdvec cs_cmdtree; E helpvec cs_helptree; bool _modinit (module *m) { cs_cmdtree << cs_invite; help_addentry (cs_helptree, "INVITE", "help/chanserv/invite", NULL); return true; } void _moddeinit () { cs_cmdtree >> cs_invite; help_delentry (cs_helptree, "INVITE"); } static void cs_cmd_invite (sourceinfo_t *si, int parc, char *parv[]) { char *chan = parv[0]; mychan_t *mc; if (si->su == NULL) { command_fail (si, fault::noprivs, _("\2%s\2 can only be executed via IRC."), "INVITE"); return; } if (!chan) { command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "INVITE"); command_fail (si, fault::needmoreparams, _("Syntax: INVITE <#channel>")); return; } mc = mychan_t::find (chan); if (!mc) { command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), chan); return; } if (mc->find_metadata ("private:close:closer")) { command_fail (si, fault::noprivs, _("\2%s\2 is closed."), chan); return; } if (!chanacs_source_has_flag (mc, si, CA_INVITE)) { command_fail (si, fault::noprivs, _("You are not authorized to perform this operation.")); return; } if (chanuser_find (mc->chan, si->su)) { command_fail (si, fault::noprivs, _("You're already on \2%s\2."), mc->name); return; } if (!mc->chan) { command_fail (si, fault::nosuch_target, _("\2%s\2 is currently empty."), mc->name); return; } phandler->invite_sts (si->service->me, si->su, mc->chan); logcommand (si, CMDLOG_SET, "%s INVITE", mc->name); command_success_nodata (si, _("You have been invited to \2%s\2."), mc->name); }