| 1 |
pippijn |
1.7 |
/** |
| 2 |
|
|
* mark.C: Marking for nicknames. |
| 3 |
|
|
* |
| 4 |
|
|
* Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team |
| 5 |
|
|
* Rights to this code are as documented in COPYING. |
| 6 |
|
|
* |
| 7 |
|
|
* |
| 8 |
|
|
* Portions of this file were derived from sources bearing the following license: |
| 9 |
pippijn |
1.4 |
* Copyright © 2005 William Pitcock |
| 10 |
pippijn |
1.2 |
* Rights to this code are as documented in doc/pod/license.pod. |
| 11 |
pippijn |
1.1 |
* |
| 12 |
pippijn |
1.8 |
* $Id: mark.C,v 1.7 2007-09-16 18:54:43 pippijn Exp $ |
| 13 |
pippijn |
1.1 |
*/ |
| 14 |
|
|
|
| 15 |
|
|
#include "atheme.h" |
| 16 |
pippijn |
1.8 |
#include <util/numeric.h> |
| 17 |
|
|
#include <libermyth.h> |
| 18 |
pippijn |
1.4 |
#include <ermyth/module.h> |
| 19 |
pippijn |
1.1 |
#include <account/myuser.h> |
| 20 |
|
|
|
| 21 |
pippijn |
1.8 |
static char const rcsid[] = "$Id: mark.C,v 1.7 2007-09-16 18:54:43 pippijn Exp $"; |
| 22 |
pippijn |
1.1 |
|
| 23 |
pippijn |
1.8 |
REGISTER_MODULE ("nickserv/mark", false, "The Ermyth Team <http://ermyth.xinutec.org>"); |
| 24 |
pippijn |
1.1 |
|
| 25 |
|
|
static void ns_cmd_mark (sourceinfo_t *si, int parc, char *parv[]); |
| 26 |
|
|
|
| 27 |
pippijn |
1.4 |
command_t const ns_mark = { "MARK", N_("Adds a note to a user."), PRIV_MARK, 3, ns_cmd_mark }; |
| 28 |
pippijn |
1.1 |
|
| 29 |
pippijn |
1.4 |
E cmdvec ns_cmdtree; |
| 30 |
|
|
E helpvec ns_helptree; |
| 31 |
pippijn |
1.1 |
|
| 32 |
pippijn |
1.4 |
bool |
| 33 |
|
|
_modinit (module *m) |
| 34 |
pippijn |
1.1 |
{ |
| 35 |
|
|
ns_cmdtree << ns_mark; |
| 36 |
|
|
help_addentry (ns_helptree, "MARK", "help/nickserv/mark", NULL); |
| 37 |
pippijn |
1.4 |
|
| 38 |
|
|
return true; |
| 39 |
pippijn |
1.1 |
} |
| 40 |
|
|
|
| 41 |
|
|
void |
| 42 |
|
|
_moddeinit () |
| 43 |
|
|
{ |
| 44 |
|
|
ns_cmdtree >> ns_mark; |
| 45 |
|
|
help_delentry (ns_helptree, "MARK"); |
| 46 |
|
|
} |
| 47 |
|
|
|
| 48 |
|
|
static void |
| 49 |
|
|
ns_cmd_mark (sourceinfo_t *si, int parc, char *parv[]) |
| 50 |
|
|
{ |
| 51 |
|
|
char *target = parv[0]; |
| 52 |
|
|
char *action = parv[1]; |
| 53 |
|
|
char *info = parv[2]; |
| 54 |
|
|
myuser_t *mu; |
| 55 |
|
|
|
| 56 |
|
|
if (!target || !action) |
| 57 |
|
|
{ |
| 58 |
pippijn |
1.6 |
command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "MARK"); |
| 59 |
|
|
command_fail (si, fault::needmoreparams, _("Usage: MARK <target> <ON|OFF> [note]")); |
| 60 |
pippijn |
1.1 |
return; |
| 61 |
|
|
} |
| 62 |
|
|
|
| 63 |
pippijn |
1.5 |
if (!(mu = myuser_t::find_ext (target))) |
| 64 |
pippijn |
1.1 |
{ |
| 65 |
pippijn |
1.6 |
command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), target); |
| 66 |
pippijn |
1.1 |
return; |
| 67 |
|
|
} |
| 68 |
|
|
|
| 69 |
|
|
if (!strcasecmp (action, "ON")) |
| 70 |
|
|
{ |
| 71 |
|
|
if (!info) |
| 72 |
|
|
{ |
| 73 |
pippijn |
1.6 |
command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "MARK"); |
| 74 |
|
|
command_fail (si, fault::needmoreparams, _("Usage: MARK <target> ON <note>")); |
| 75 |
pippijn |
1.1 |
return; |
| 76 |
|
|
} |
| 77 |
|
|
|
| 78 |
|
|
if (mu->find_metadata ("private:mark:setter")) |
| 79 |
|
|
{ |
| 80 |
pippijn |
1.6 |
command_fail (si, fault::badparams, _("\2%s\2 is already marked."), target); |
| 81 |
pippijn |
1.1 |
return; |
| 82 |
|
|
} |
| 83 |
|
|
|
| 84 |
|
|
mu->add_metadata ("private:mark:setter", get_oper_name (si)); |
| 85 |
|
|
mu->add_metadata ("private:mark:reason", info); |
| 86 |
pippijn |
1.4 |
mu->add_metadata ("private:mark:timestamp", itoa (NOW)); |
| 87 |
pippijn |
1.1 |
|
| 88 |
|
|
wallops ("%s marked the nickname \2%s\2.", get_oper_name (si), target); |
| 89 |
|
|
logcommand (si, CMDLOG_ADMIN, "MARK %s ON (reason: %s)", target, info); |
| 90 |
|
|
command_success_nodata (si, _("\2%s\2 is now marked."), target); |
| 91 |
|
|
} |
| 92 |
|
|
else if (!strcasecmp (action, "OFF")) |
| 93 |
|
|
{ |
| 94 |
|
|
if (!mu->find_metadata ("private:mark:setter")) |
| 95 |
|
|
{ |
| 96 |
pippijn |
1.6 |
command_fail (si, fault::badparams, _("\2%s\2 is not marked."), target); |
| 97 |
pippijn |
1.1 |
return; |
| 98 |
|
|
} |
| 99 |
|
|
|
| 100 |
|
|
mu->del_metadata ("private:mark:setter"); |
| 101 |
|
|
mu->del_metadata ("private:mark:reason"); |
| 102 |
|
|
mu->del_metadata ("private:mark:timestamp"); |
| 103 |
|
|
|
| 104 |
|
|
wallops ("%s unmarked the nickname \2%s\2.", get_oper_name (si), target); |
| 105 |
|
|
logcommand (si, CMDLOG_ADMIN, "MARK %s OFF", target); |
| 106 |
|
|
command_success_nodata (si, _("\2%s\2 is now unmarked."), target); |
| 107 |
|
|
} |
| 108 |
|
|
else |
| 109 |
|
|
{ |
| 110 |
pippijn |
1.6 |
command_fail (si, fault::needmoreparams, STR_INVALID_PARAMS, "MARK"); |
| 111 |
|
|
command_fail (si, fault::needmoreparams, _("Usage: MARK <target> <ON|OFF> [note]")); |
| 112 |
pippijn |
1.1 |
} |
| 113 |
|
|
} |