/** * mark.C: Marking for channels. * * 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 * Rights to this code are as documented in doc/pod/license.pod. * * $Id: mark.C,v 1.8 2007/09/22 14:27:27 pippijn Exp $ */ #include "atheme.h" #include #include #include #include static char const rcsid[] = "$Id: mark.C,v 1.8 2007/09/22 14:27:27 pippijn Exp $"; REGISTER_MODULE ("chanserv/mark", false, "The Ermyth Team "); static void cs_cmd_mark (sourceinfo_t *si, int parc, char *parv[]); command_t const cs_mark = { "MARK", N_("Adds a note to a channel."), PRIV_MARK, 3, cs_cmd_mark }; E cmdvec cs_cmdtree; E helpvec cs_helptree; bool _modinit (module *m) { cs_cmdtree << cs_mark; help_addentry (cs_helptree, "MARK", "help/chanserv/mark", NULL); return true; } void _moddeinit () { cs_cmdtree >> cs_mark; help_delentry (cs_helptree, "MARK"); } static void cs_cmd_mark (sourceinfo_t *si, int parc, char *parv[]) { char *target = parv[0]; char *action = parv[1]; char *info = parv[2]; mychan_t *mc; if (!target || !action) { command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "MARK"); command_fail (si, fault::needmoreparams, _("Usage: MARK <#channel> [note]")); return; } if (target[0] != '#') { command_fail (si, fault::badparams, STR_INVALID_PARAMS, "MARK"); return; } if (!(mc = mychan_t::find (target))) { command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), target); return; } if (!strcasecmp (action, "ON")) { if (!info) { command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "MARK"); command_fail (si, fault::needmoreparams, _("Usage: MARK <#channel> ON ")); return; } if (mc->find_metadata ("private:mark:setter")) { command_fail (si, fault::nochange, _("\2%s\2 is already marked."), target); return; } mc->add_metadata ("private:mark:setter", get_oper_name (si)); mc->add_metadata ("private:mark:reason", info); mc->add_metadata ("private:mark:timestamp", itoa (NOW)); wallops ("%s marked the channel \2%s\2.", get_oper_name (si), target); logcommand (si, CMDLOG_ADMIN, "%s MARK ON", mc->name); command_success_nodata (si, _("\2%s\2 is now marked."), target); } else if (!strcasecmp (action, "OFF")) { if (!mc->find_metadata ("private:mark:setter")) { command_fail (si, fault::nochange, _("\2%s\2 is not marked."), target); return; } mc->del_metadata ("private:mark:setter"); mc->del_metadata ("private:mark:reason"); mc->del_metadata ("private:mark:timestamp"); wallops ("%s unmarked the channel \2%s\2.", get_oper_name (si), target); logcommand (si, CMDLOG_ADMIN, "%s MARK OFF", mc->name); command_success_nodata (si, _("\2%s\2 is now unmarked."), target); } else { command_fail (si, fault::badparams, STR_INVALID_PARAMS, "MARK"); command_fail (si, fault::badparams, _("Usage: MARK <#channel> [note]")); } } /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs * vim:ts=8 * vim:sw=8 * vim:noexpandtab */