1 |
/** |
2 |
* hold.C: Controls noexpire options 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 |
* Copyright © 2005 Atheme Development Group |
10 |
* Rights to this code are as documented in doc/pod/license.pod. |
11 |
* |
12 |
* $Id: hold.C,v 1.7 2007-09-16 18:54:43 pippijn Exp $ |
13 |
*/ |
14 |
|
15 |
#include "atheme.h" |
16 |
#include <ermyth/module.h> |
17 |
#include <account/myuser.h> |
18 |
|
19 |
static char const rcsid[] = "$Id: hold.C,v 1.7 2007-09-16 18:54:43 pippijn Exp $"; |
20 |
|
21 |
REGISTER_MODULE ("nickserv/hold", false, "The Ermyth Team <http://ermyth.xinutec.org>"); |
22 |
|
23 |
static void ns_cmd_hold (sourceinfo_t *si, int parc, char *parv[]); |
24 |
|
25 |
command_t const ns_hold = { "HOLD", N_("Prevents an account from expiring."), PRIV_HOLD, 2, ns_cmd_hold }; |
26 |
|
27 |
E cmdvec ns_cmdtree; |
28 |
E helpvec ns_helptree; |
29 |
|
30 |
bool |
31 |
_modinit (module *m) |
32 |
{ |
33 |
ns_cmdtree << ns_hold; |
34 |
help_addentry (ns_helptree, "HOLD", "help/nickserv/hold", NULL); |
35 |
|
36 |
return true; |
37 |
} |
38 |
|
39 |
void |
40 |
_moddeinit () |
41 |
{ |
42 |
ns_cmdtree >> ns_hold; |
43 |
help_delentry (ns_helptree, "HOLD"); |
44 |
} |
45 |
|
46 |
static void |
47 |
ns_cmd_hold (sourceinfo_t *si, int parc, char *parv[]) |
48 |
{ |
49 |
char *target = parv[0]; |
50 |
char *action = parv[1]; |
51 |
myuser_t *mu; |
52 |
|
53 |
if (!target || !action) |
54 |
{ |
55 |
command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "HOLD"); |
56 |
command_fail (si, fault::needmoreparams, _("Usage: HOLD <account> <ON|OFF>")); |
57 |
return; |
58 |
} |
59 |
|
60 |
if (!(mu = myuser_t::find_ext (target))) |
61 |
{ |
62 |
command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), target); |
63 |
return; |
64 |
} |
65 |
|
66 |
if (!strcasecmp (action, "ON")) |
67 |
{ |
68 |
if (mu->flags & MU_HOLD) |
69 |
{ |
70 |
command_fail (si, fault::badparams, _("\2%s\2 is already held."), mu->name); |
71 |
return; |
72 |
} |
73 |
|
74 |
mu->flags |= MU_HOLD; |
75 |
|
76 |
wallops ("%s set the HOLD option for the account \2%s\2.", get_oper_name (si), mu->name); |
77 |
logcommand (si, CMDLOG_ADMIN, "HOLD %s ON", mu->name); |
78 |
command_success_nodata (si, _("\2%s\2 is now held."), mu->name); |
79 |
} |
80 |
else if (!strcasecmp (action, "OFF")) |
81 |
{ |
82 |
if (!(mu->flags & MU_HOLD)) |
83 |
{ |
84 |
command_fail (si, fault::badparams, _("\2%s\2 is not held."), mu->name); |
85 |
return; |
86 |
} |
87 |
|
88 |
mu->flags &= ~MU_HOLD; |
89 |
|
90 |
wallops ("%s removed the HOLD option on the account \2%s\2.", get_oper_name (si), mu->name); |
91 |
logcommand (si, CMDLOG_ADMIN, "HOLD %s OFF", mu->name); |
92 |
command_success_nodata (si, _("\2%s\2 is no longer held."), mu->name); |
93 |
} |
94 |
else |
95 |
{ |
96 |
command_fail (si, fault::needmoreparams, STR_INVALID_PARAMS, "HOLD"); |
97 |
command_fail (si, fault::needmoreparams, _("Usage: HOLD <account> <ON|OFF>")); |
98 |
} |
99 |
} |
100 |
|
101 |
/* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs |
102 |
* vim:ts=8 |
103 |
* vim:sw=8 |
104 |
* vim:noexpandtab |
105 |
*/ |