ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/chanserv/getkey.C
Revision: 1.6
Committed: Thu Aug 30 19:56:21 2007 UTC (19 years, 1 month ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.5: +10 -10 lines
Log Message:
- put faultcodes into their own namespace
- removed old files
- limited header garbage in atheme.h
- macros to inline bools for connection_t::is_*
- put some connection_t functions into the connection_t class

File Contents

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