| 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 ENTRYMSG command. |
| 7 |
* |
| 8 |
*/ |
| 9 |
|
| 10 |
#include "atheme.h" |
| 11 |
|
| 12 |
DECLARE_MODULE_V1 |
| 13 |
( |
| 14 |
"chanserv/set_entrymsg", false, _modinit, _moddeinit, |
| 15 |
PACKAGE_STRING, |
| 16 |
VENDOR_STRING |
| 17 |
); |
| 18 |
|
| 19 |
static void cs_cmd_set_entrymsg(sourceinfo_t *si, int parc, char *parv[]); |
| 20 |
|
| 21 |
command_t cs_set_entrymsg = { "ENTRYMSG", N_("Sets the channel's entry message."), AC_NONE, 2, cs_cmd_set_entrymsg, { .path = "cservice/set_entrymsg" } }; |
| 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_entrymsg, *cs_set_cmdtree); |
| 30 |
} |
| 31 |
|
| 32 |
void _moddeinit(module_unload_intent_t intent) |
| 33 |
{ |
| 34 |
command_delete(&cs_set_entrymsg, *cs_set_cmdtree); |
| 35 |
} |
| 36 |
|
| 37 |
static void cs_cmd_set_entrymsg(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 (!chanacs_source_has_flag(mc, si, CA_SET)) |
| 48 |
{ |
| 49 |
command_fail(si, fault_noprivs, _("You are not authorized to execute this command.")); |
| 50 |
return; |
| 51 |
} |
| 52 |
|
| 53 |
if (!parv[1] || !strcasecmp("OFF", parv[1]) || !strcasecmp("NONE", parv[1])) |
| 54 |
{ |
| 55 |
/* entrymsg is private because users won't see it if they're AKICKED, |
| 56 |
* if the channel is +i, or if the channel is RESTRICTED |
| 57 |
*/ |
| 58 |
if (metadata_find(mc, "private:entrymsg")) |
| 59 |
{ |
| 60 |
metadata_delete(mc, "private:entrymsg"); |
| 61 |
logcommand(si, CMDLOG_SET, "SET:ENTRYMSG:NONE: \2%s\2", mc->name); |
| 62 |
verbose(mc, _("\2%s\2 cleared the entry message"), get_source_name(si)); |
| 63 |
command_success_nodata(si, _("The entry message for \2%s\2 has been cleared."), parv[0]); |
| 64 |
return; |
| 65 |
} |
| 66 |
|
| 67 |
command_fail(si, fault_nochange, _("The entry message for \2%s\2 was not set."), parv[0]); |
| 68 |
return; |
| 69 |
} |
| 70 |
|
| 71 |
/* we'll overwrite any existing metadata. |
| 72 |
* Why is/was this even private? There are no size/content sanity checks |
| 73 |
* and even users with no channel access can see it. --jdhore |
| 74 |
*/ |
| 75 |
metadata_add(mc, "private:entrymsg", parv[1]); |
| 76 |
|
| 77 |
logcommand(si, CMDLOG_SET, "SET:ENTRYMSG: \2%s\2 \2%s\2", mc->name, parv[1]); |
| 78 |
verbose(mc, _("\2%s\2 set the entry message for the channel to \2%s\2"), get_source_name(si), parv[1]); |
| 79 |
command_success_nodata(si, _("The entry message for \2%s\2 has been set to \2%s\2"), parv[0], parv[1]); |
| 80 |
} |
| 81 |
|
| 82 |
/* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs |
| 83 |
* vim:ts=8 |
| 84 |
* vim:sw=8 |
| 85 |
* vim:noexpandtab |
| 86 |
*/ |