ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/modules/chanserv/getkey.C
Revision: 1.8
Committed: Sat Sep 22 14:27:27 2007 UTC (19 years, 1 month 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     * 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 pippijn 1.5 * Copyright © 2005 William Pitcock, et al.
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: getkey.C,v 1.7 2007-09-16 18:54:42 pippijn Exp $
13 pippijn 1.1 */
14    
15     #include "atheme.h"
16 pippijn 1.5 #include <ermyth/module.h>
17 pippijn 1.1 #include <account/mychan.h>
18     #include <account/chanacs.h>
19    
20 pippijn 1.8 static char const rcsid[] = "$Id: getkey.C,v 1.7 2007-09-16 18:54:42 pippijn Exp $";
21 pippijn 1.1
22 pippijn 1.8 REGISTER_MODULE ("chanserv/getkey", false, "The Ermyth Team <http://ermyth.xinutec.org>");
23 pippijn 1.1
24     static void cs_cmd_getkey (sourceinfo_t *si, int parc, char *parv[]);
25    
26 pippijn 1.5 command_t const cs_getkey = { "GETKEY", N_("Returns the key (+k) of a channel."), AC_NONE, 1, cs_cmd_getkey };
27 pippijn 1.1
28 pippijn 1.5 E cmdvec cs_cmdtree;
29     E helpvec cs_helptree;
30 pippijn 1.1
31 pippijn 1.5 bool
32     _modinit (module *m)
33 pippijn 1.1 {
34     cs_cmdtree << cs_getkey;
35 pippijn 1.4 help_addentry (cs_helptree, "GETKEY", "help/chanserv/getkey", NULL);
36 pippijn 1.5
37     return true;
38 pippijn 1.1 }
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 pippijn 1.6 command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "GETKEY");
56     command_fail (si, fault::needmoreparams, _("Syntax: GETKEY <#channel>"));
57 pippijn 1.1 return;
58     }
59    
60 pippijn 1.6 mc = mychan_t::find (chan);
61 pippijn 1.1 if (!mc)
62     {
63 pippijn 1.6 command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), chan);
64 pippijn 1.1 return;
65     }
66    
67     if (mc->find_metadata ("private:close:closer"))
68     {
69 pippijn 1.6 command_fail (si, fault::noprivs, _("\2%s\2 is closed."), chan);
70 pippijn 1.1 return;
71     }
72    
73     if (!chanacs_source_has_flag (mc, si, CA_INVITE))
74     {
75 pippijn 1.6 command_fail (si, fault::noprivs, _("You are not authorized to perform this operation."));
76 pippijn 1.1 return;
77     }
78    
79     if (!mc->chan)
80     {
81 pippijn 1.6 command_fail (si, fault::nosuch_target, _("\2%s\2 is currently empty."), mc->name);
82 pippijn 1.1 return;
83     }
84    
85     if (!mc->chan->key)
86     {
87 pippijn 1.6 command_fail (si, fault::nosuch_key, _("\2%s\2 is not keyed."), mc->name);
88 pippijn 1.1 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     */