/** * mark.C: Marking for nicknames. * * 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:28 pippijn Exp $ */ #include "atheme.h" #include #include #include #include static char const rcsid[] = "$Id: mark.C,v 1.8 2007/09/22 14:27:28 pippijn Exp $"; REGISTER_MODULE ("nickserv/mark", false, "The Ermyth Team "); static void ns_cmd_mark (sourceinfo_t *si, int parc, char *parv[]); command_t const ns_mark = { "MARK", N_("Adds a note to a user."), PRIV_MARK, 3, ns_cmd_mark }; E cmdvec ns_cmdtree; E helpvec ns_helptree; bool _modinit (module *m) { ns_cmdtree << ns_mark; help_addentry (ns_helptree, "MARK", "help/nickserv/mark", NULL); return true; } void _moddeinit () { ns_cmdtree >> ns_mark; help_delentry (ns_helptree, "MARK"); } static void ns_cmd_mark (sourceinfo_t *si, int parc, char *parv[]) { char *target = parv[0]; char *action = parv[1]; char *info = parv[2]; myuser_t *mu; if (!target || !action) { command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "MARK"); command_fail (si, fault::needmoreparams, _("Usage: MARK [note]")); return; } if (!(mu = myuser_t::find_ext (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 ON ")); return; } if (mu->find_metadata ("private:mark:setter")) { command_fail (si, fault::badparams, _("\2%s\2 is already marked."), target); return; } mu->add_metadata ("private:mark:setter", get_oper_name (si)); mu->add_metadata ("private:mark:reason", info); mu->add_metadata ("private:mark:timestamp", itoa (NOW)); wallops ("%s marked the nickname \2%s\2.", get_oper_name (si), target); logcommand (si, CMDLOG_ADMIN, "MARK %s ON (reason: %s)", target, info); command_success_nodata (si, _("\2%s\2 is now marked."), target); } else if (!strcasecmp (action, "OFF")) { if (!mu->find_metadata ("private:mark:setter")) { command_fail (si, fault::badparams, _("\2%s\2 is not marked."), target); return; } mu->del_metadata ("private:mark:setter"); mu->del_metadata ("private:mark:reason"); mu->del_metadata ("private:mark:timestamp"); wallops ("%s unmarked the nickname \2%s\2.", get_oper_name (si), target); logcommand (si, CMDLOG_ADMIN, "MARK %s OFF", target); command_success_nodata (si, _("\2%s\2 is now unmarked."), target); } else { command_fail (si, fault::needmoreparams, STR_INVALID_PARAMS, "MARK"); command_fail (si, fault::needmoreparams, _("Usage: MARK [note]")); } }