| 1 |
/* |
| 2 |
* Copyright (c) 2003-2004 E. Will et al. |
| 3 |
* Copyright (c) 2006-2010 Atheme Development Group |
| 4 |
* Rights to this code are documented in doc/LICENSE. |
| 5 |
* |
| 6 |
* This file contains routines to handle the CService SET RESTRICTED command. |
| 7 |
* |
| 8 |
*/ |
| 9 |
|
| 10 |
#include "atheme.h" |
| 11 |
|
| 12 |
DECLARE_MODULE_V1 |
| 13 |
( |
| 14 |
"chanserv/set_restricted", false, _modinit, _moddeinit, |
| 15 |
PACKAGE_STRING, |
| 16 |
VENDOR_STRING |
| 17 |
); |
| 18 |
|
| 19 |
static void cs_cmd_set_restricted(sourceinfo_t *si, int parc, char *parv[]); |
| 20 |
|
| 21 |
command_t cs_set_restricted = { "RESTRICTED", N_("Restricts access to the channel to users on the access list. (Other users are kickbanned.)"), AC_NONE, 2, cs_cmd_set_restricted, { .path = "cservice/set_restricted" } }; |
| 22 |
|
| 23 |
mowgli_patricia_t **cs_set_cmdtree; |
| 24 |
|
| 25 |
void _modinit(module_t *m) |
| 26 |
{ |
| 27 |
MODULE_TRY_REQUEST_SYMBOL(m, cs_set_cmdtree, "chanserv/set_core", "cs_set_cmdtree"); |
| 28 |
|
| 29 |
command_add(&cs_set_restricted, *cs_set_cmdtree); |
| 30 |
} |
| 31 |
|
| 32 |
void _moddeinit(module_unload_intent_t intent) |
| 33 |
{ |
| 34 |
command_delete(&cs_set_restricted, *cs_set_cmdtree); |
| 35 |
} |
| 36 |
|
| 37 |
static void cs_cmd_set_restricted(sourceinfo_t *si, int parc, char *parv[]) |
| 38 |
{ |
| 39 |
mychan_t *mc; |
| 40 |
|
| 41 |
if (!(mc = mychan_find(parv[0]))) |
| 42 |
{ |
| 43 |
command_fail(si, fault_nosuch_target, _("Channel \2%s\2 is not registered."), parv[0]); |
| 44 |
return; |
| 45 |
} |
| 46 |
|
| 47 |
if (!parv[1]) |
| 48 |
{ |
| 49 |
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "SET RESTRICTED"); |
| 50 |
return; |
| 51 |
} |
| 52 |
|
| 53 |
if (!chanacs_source_has_flag(mc, si, CA_SET)) |
| 54 |
{ |
| 55 |
command_fail(si, fault_noprivs, _("You are not authorized to perform this command.")); |
| 56 |
return; |
| 57 |
} |
| 58 |
|
| 59 |
if (!strcasecmp("ON", parv[1])) |
| 60 |
{ |
| 61 |
if (MC_RESTRICTED & mc->flags) |
| 62 |
{ |
| 63 |
command_fail(si, fault_nochange, _("The \2%s\2 flag is already set for channel \2%s\2."), "RESTRICTED", mc->name); |
| 64 |
return; |
| 65 |
} |
| 66 |
|
| 67 |
logcommand(si, CMDLOG_SET, "SET:RESTRICTED:ON: \2%s\2", mc->name); |
| 68 |
verbose(mc, _("\2%s\2 enabled the RESTRICTED flag"), get_source_name(si)); |
| 69 |
|
| 70 |
mc->flags |= MC_RESTRICTED; |
| 71 |
|
| 72 |
command_success_nodata(si, _("The \2%s\2 flag has been set for channel \2%s\2."), "RESTRICTED", mc->name); |
| 73 |
return; |
| 74 |
} |
| 75 |
else if (!strcasecmp("OFF", parv[1])) |
| 76 |
{ |
| 77 |
if (!(MC_RESTRICTED & mc->flags)) |
| 78 |
{ |
| 79 |
command_fail(si, fault_nochange, _("The \2%s\2 flag is not set for channel \2%s\2."), "RESTRICTED", mc->name); |
| 80 |
return; |
| 81 |
} |
| 82 |
|
| 83 |
logcommand(si, CMDLOG_SET, "SET:RESTRICTED:OFF: \2%s\2", mc->name); |
| 84 |
verbose(mc, _("\2%s\2 disabled the RESTRICTED flag"), get_source_name(si)); |
| 85 |
|
| 86 |
mc->flags &= ~MC_RESTRICTED; |
| 87 |
|
| 88 |
command_success_nodata(si, _("The \2%s\2 flag has been removed for channel \2%s\2."), "RESTRICTED", mc->name); |
| 89 |
return; |
| 90 |
} |
| 91 |
else |
| 92 |
{ |
| 93 |
command_fail(si, fault_badparams, STR_INVALID_PARAMS, "RESTRICTED"); |
| 94 |
return; |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
/* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs |
| 99 |
* vim:ts=8 |
| 100 |
* vim:sw=8 |
| 101 |
* vim:noexpandtab |
| 102 |
*/ |