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