ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/nickserv/hold.C
Revision: 1.8
Committed: Sat Sep 22 14:27:27 2007 UTC (19 years ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +3 -3 lines
Log Message:
split up ermyth into ermyth-modules, libermyth (currently just ermyth-util) and ermyth-core

File Contents

# User Rev Content
1 pippijn 1.7 /**
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 pippijn 1.4 * Copyright © 2005 Atheme Development Group
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: hold.C,v 1.7 2007-09-16 18:54:43 pippijn Exp $
13 pippijn 1.1 */
14    
15     #include "atheme.h"
16 pippijn 1.4 #include <ermyth/module.h>
17 pippijn 1.1 #include <account/myuser.h>
18    
19 pippijn 1.8 static char const rcsid[] = "$Id: hold.C,v 1.7 2007-09-16 18:54:43 pippijn Exp $";
20 pippijn 1.1
21 pippijn 1.8 REGISTER_MODULE ("nickserv/hold", false, "The Ermyth Team <http://ermyth.xinutec.org>");
22 pippijn 1.1
23     static void ns_cmd_hold (sourceinfo_t *si, int parc, char *parv[]);
24    
25 pippijn 1.4 command_t const ns_hold = { "HOLD", N_("Prevents an account from expiring."), PRIV_HOLD, 2, ns_cmd_hold };
26 pippijn 1.1
27 pippijn 1.4 E cmdvec ns_cmdtree;
28     E helpvec ns_helptree;
29 pippijn 1.1
30 pippijn 1.4 bool
31     _modinit (module *m)
32 pippijn 1.1 {
33     ns_cmdtree << ns_hold;
34     help_addentry (ns_helptree, "HOLD", "help/nickserv/hold", NULL);
35 pippijn 1.4
36     return true;
37 pippijn 1.1 }
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 pippijn 1.6 command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "HOLD");
56     command_fail (si, fault::needmoreparams, _("Usage: HOLD <account> <ON|OFF>"));
57 pippijn 1.1 return;
58     }
59    
60 pippijn 1.5 if (!(mu = myuser_t::find_ext (target)))
61 pippijn 1.1 {
62 pippijn 1.6 command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), target);
63 pippijn 1.1 return;
64     }
65    
66     if (!strcasecmp (action, "ON"))
67     {
68     if (mu->flags & MU_HOLD)
69     {
70 pippijn 1.6 command_fail (si, fault::badparams, _("\2%s\2 is already held."), mu->name);
71 pippijn 1.1 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 pippijn 1.6 command_fail (si, fault::badparams, _("\2%s\2 is not held."), mu->name);
85 pippijn 1.1 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 pippijn 1.6 command_fail (si, fault::needmoreparams, STR_INVALID_PARAMS, "HOLD");
97     command_fail (si, fault::needmoreparams, _("Usage: HOLD <account> <ON|OFF>"));
98 pippijn 1.1 }
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     */