1 |
/** |
2 |
* getkey.C: This file contains code for the ChanServ GETKEY functions. |
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 William Pitcock, et al. |
10 |
* Rights to this code are as documented in doc/pod/license.pod. |
11 |
* |
12 |
* $Id: getkey.C,v 1.7 2007-09-16 18:54:42 pippijn Exp $ |
13 |
*/ |
14 |
|
15 |
#include "atheme.h" |
16 |
#include <ermyth/module.h> |
17 |
#include <account/mychan.h> |
18 |
#include <account/chanacs.h> |
19 |
|
20 |
static char const rcsid[] = "$Id: getkey.C,v 1.7 2007-09-16 18:54:42 pippijn Exp $"; |
21 |
|
22 |
REGISTER_MODULE ("chanserv/getkey", false, "The Ermyth Team <http://ermyth.xinutec.org>"); |
23 |
|
24 |
static void cs_cmd_getkey (sourceinfo_t *si, int parc, char *parv[]); |
25 |
|
26 |
command_t const cs_getkey = { "GETKEY", N_("Returns the key (+k) of a channel."), AC_NONE, 1, cs_cmd_getkey }; |
27 |
|
28 |
E cmdvec cs_cmdtree; |
29 |
E helpvec cs_helptree; |
30 |
|
31 |
bool |
32 |
_modinit (module *m) |
33 |
{ |
34 |
cs_cmdtree << cs_getkey; |
35 |
help_addentry (cs_helptree, "GETKEY", "help/chanserv/getkey", NULL); |
36 |
|
37 |
return true; |
38 |
} |
39 |
|
40 |
void |
41 |
_moddeinit () |
42 |
{ |
43 |
cs_cmdtree >> cs_getkey; |
44 |
help_delentry (cs_helptree, "GETKEY"); |
45 |
} |
46 |
|
47 |
static void |
48 |
cs_cmd_getkey (sourceinfo_t *si, int parc, char *parv[]) |
49 |
{ |
50 |
char *chan = parv[0]; |
51 |
mychan_t *mc; |
52 |
|
53 |
if (!chan) |
54 |
{ |
55 |
command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "GETKEY"); |
56 |
command_fail (si, fault::needmoreparams, _("Syntax: GETKEY <#channel>")); |
57 |
return; |
58 |
} |
59 |
|
60 |
mc = mychan_t::find (chan); |
61 |
if (!mc) |
62 |
{ |
63 |
command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), chan); |
64 |
return; |
65 |
} |
66 |
|
67 |
if (mc->find_metadata ("private:close:closer")) |
68 |
{ |
69 |
command_fail (si, fault::noprivs, _("\2%s\2 is closed."), chan); |
70 |
return; |
71 |
} |
72 |
|
73 |
if (!chanacs_source_has_flag (mc, si, CA_INVITE)) |
74 |
{ |
75 |
command_fail (si, fault::noprivs, _("You are not authorized to perform this operation.")); |
76 |
return; |
77 |
} |
78 |
|
79 |
if (!mc->chan) |
80 |
{ |
81 |
command_fail (si, fault::nosuch_target, _("\2%s\2 is currently empty."), mc->name); |
82 |
return; |
83 |
} |
84 |
|
85 |
if (!mc->chan->key) |
86 |
{ |
87 |
command_fail (si, fault::nosuch_key, _("\2%s\2 is not keyed."), mc->name); |
88 |
return; |
89 |
} |
90 |
logcommand (si, CMDLOG_GET, "%s GETKEY", mc->name); |
91 |
command_success_string (si, mc->chan->key, _("Channel \2%s\2 key is: %s"), mc->name, mc->chan->key); |
92 |
} |
93 |
|
94 |
/* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs |
95 |
* vim:ts=8 |
96 |
* vim:sw=8 |
97 |
* vim:noexpandtab |
98 |
*/ |