1 |
/** |
2 |
* jupe.C: Jupiters a server. |
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-2006 William Pitcock, et al. |
10 |
* Rights to this code are as documented in doc/pod/license.pod. |
11 |
* |
12 |
* $Id: jupe.C,v 1.7 2007-09-16 18:54:44 pippijn Exp $ |
13 |
*/ |
14 |
|
15 |
#include "atheme.h" |
16 |
#include <ermyth/module.h> |
17 |
|
18 |
static char const rcsid[] = "$Id: jupe.C,v 1.7 2007-09-16 18:54:44 pippijn Exp $"; |
19 |
|
20 |
REGISTER_MODULE ("operserv/jupe", false, "The Ermyth Team <http://ermyth.xinutec.org>"); |
21 |
|
22 |
static void os_cmd_jupe (sourceinfo_t *si, int parc, char *parv[]); |
23 |
|
24 |
command_t const os_jupe = { "JUPE", N_("Jupiters a server."), PRIV_JUPE, 2, os_cmd_jupe }; |
25 |
|
26 |
E cmdvec os_cmdtree; |
27 |
E helpvec os_helptree; |
28 |
|
29 |
bool |
30 |
_modinit (module *m) |
31 |
{ |
32 |
os_cmdtree << os_jupe; |
33 |
help_addentry (os_helptree, "JUPE", "help/operserv/jupe", NULL); |
34 |
|
35 |
return true; |
36 |
} |
37 |
|
38 |
void |
39 |
_moddeinit () |
40 |
{ |
41 |
os_cmdtree >> os_jupe; |
42 |
help_delentry (os_helptree, "JUPE"); |
43 |
} |
44 |
|
45 |
static void |
46 |
os_cmd_jupe (sourceinfo_t *si, int parc, char *parv[]) |
47 |
{ |
48 |
char *server = parv[0]; |
49 |
char *reason = parv[1]; |
50 |
char reasonbuf[BUFSIZE]; |
51 |
|
52 |
if (!server || !reason) |
53 |
{ |
54 |
command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "JUPE"); |
55 |
command_fail (si, fault::needmoreparams, _("Usage: JUPE <server> <reason>")); |
56 |
return; |
57 |
} |
58 |
|
59 |
if (!strchr (server, '.')) |
60 |
{ |
61 |
command_fail (si, fault::badparams, _("\2%s\2 is not a valid server name."), server); |
62 |
return; |
63 |
} |
64 |
|
65 |
if (!irccasecmp (server, me.name)) |
66 |
{ |
67 |
command_fail (si, fault::noprivs, _("\2%s\2 is the services server; it cannot be jupitered!"), server); |
68 |
return; |
69 |
} |
70 |
|
71 |
if (!irccasecmp (server, me.actual)) |
72 |
{ |
73 |
command_fail (si, fault::noprivs, _("\2%s\2 is the current uplink; it cannot be jupitered!"), server); |
74 |
return; |
75 |
} |
76 |
|
77 |
logcommand (si, CMDLOG_ADMIN, "JUPE %s %s", server, reason); |
78 |
|
79 |
snprintf (reasonbuf, BUFSIZE, "[%s] %s", get_oper_name (si), reason); |
80 |
phandler->jupe (server, reasonbuf); |
81 |
|
82 |
command_success_nodata (si, _("\2%s\2 has been jupitered."), server); |
83 |
} |