1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
/*
* Copyright (c) 2005 William Pitcock <nenolod -at- nenolod.net>
* Copyright (c) 2007 Jilles Tjoelker
* Rights to this code are as documented in doc/LICENSE.
*
* Disables the ability to receive memos.
*
*/
#include "atheme.h"
#include "uplink.h"
#include "list.h"
DECLARE_MODULE_V1
(
"nickserv/set_nomemo", false, _modinit, _moddeinit,
PACKAGE_STRING,
VENDOR_STRING
);
mowgli_patricia_t **ns_set_cmdtree;
static void ns_cmd_set_nomemo(sourceinfo_t *si, int parc, char *parv[]);
command_t ns_set_nomemo = { "NOMEMO", N_("Disables the ability to receive memos."), AC_NONE, 1, ns_cmd_set_nomemo, { .path = "nickserv/set_nomemo" } };
static bool has_nomemo(const mynick_t *mn, const void *arg)
{
myuser_t *mu = mn->owner;
return ( mu->flags & MU_NOMEMO ) == MU_NOMEMO;
}
void _modinit(module_t *m)
{
MODULE_TRY_REQUEST_SYMBOL(m, ns_set_cmdtree, "nickserv/set_core", "ns_set_cmdtree");
command_add(&ns_set_nomemo, *ns_set_cmdtree);
use_nslist_main_symbols(m);
static list_param_t nomemo;
nomemo.opttype = OPT_BOOL;
nomemo.is_match = has_nomemo;
list_register("nomemo", &nomemo);
}
void _moddeinit(module_unload_intent_t intent)
{
command_delete(&ns_set_nomemo, *ns_set_cmdtree);
list_unregister("nomemo");
}
/* SET NOMEMO [ON|OFF] */
static void ns_cmd_set_nomemo(sourceinfo_t *si, int parc, char *parv[])
{
char *params = parv[0];
if (!params)
{
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "NOMEMO");
return;
}
if (!strcasecmp("ON", params))
{
if (MU_NOMEMO & si->smu->flags)
{
command_fail(si, fault_nochange, _("The \2%s\2 flag is already set for account \2%s\2."), "NOMEMO", entity(si->smu)->name);
return;
}
logcommand(si, CMDLOG_SET, "SET:NOMEMO:ON");
si->smu->flags |= MU_NOMEMO;
command_success_nodata(si, _("The \2%s\2 flag has been set for account \2%s\2."), "NOMEMO", entity(si->smu)->name);
return;
}
else if (!strcasecmp("OFF", params))
{
if (!(MU_NOMEMO & si->smu->flags))
{
command_fail(si, fault_nochange, _("The \2%s\2 flag is not set for account \2%s\2."), "NOMEMO", entity(si->smu)->name);
return;
}
logcommand(si, CMDLOG_SET, "SET:NOMEMO:OFF");
si->smu->flags &= ~MU_NOMEMO;
command_success_nodata(si, _("The \2%s\2 flag has been removed for account \2%s\2."), "NOMEMO", entity(si->smu)->name);
return;
}
else
{
command_fail(si, fault_badparams, STR_INVALID_PARAMS, "NOMEMO");
return;
}
}
/* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
* vim:ts=8
* vim:sw=8
* vim:noexpandtab
*/
|