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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
/*
* Copyright (c) 2006-2007 William Pitcock, et al.
* Copyright (c) 2017-2018 ChatLounge IRC Network Development Team
*
* Rights to this code are documented in doc/LICENSE.
*
* This file contains routines to handle the NickServ SET PRIVMSG command.
*/
#include "atheme.h"
#include "list_common.h"
#include "list.h"
DECLARE_MODULE_V1
(
"nickserv/set_privmsg", false, _modinit, _moddeinit,
PACKAGE_STRING,
VENDOR_STRING
);
void (*add_history_entry_setting)(myuser_t *smu, myuser_t *tmu, const char *settingname, const char *setting) = NULL;
mowgli_patricia_t **ns_set_cmdtree;
/* SET PRIVMSG ON|OFF */
static void ns_cmd_set_privmsg(sourceinfo_t *si, int parc, char *parv[])
{
char *params = parv[0];
if (!params)
{
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "PRIVMSG");
return;
}
if (!strcasecmp("ON", params) || !strcasecmp("1", params) || !strcasecmp("TRUE", params))
{
if (MU_USE_PRIVMSG & si->smu->flags)
{
command_fail(si, fault_nochange, _("The \2%s\2 flag is already set for \2%s\2."), "PRIVMSG", entity(si->smu)->name);
return;
}
logcommand(si, CMDLOG_SET, "SET:PRIVMSG:ON");
si->smu->flags |= MU_USE_PRIVMSG;
command_success_nodata(si, _("The \2%s\2 flag has been set for \2%s\2."), "PRIVMSG" ,entity(si->smu)->name);
add_history_entry_setting(si->smu, si->smu, "PRIVMSG", "ON");
return;
}
else if (!strcasecmp("OFF", params) || !strcasecmp("0", params) || !strcasecmp("FALSE", params))
{
if (!(MU_USE_PRIVMSG & si->smu->flags))
{
command_fail(si, fault_nochange, _("The \2%s\2 flag is not set for \2%s\2."), "PRIVMSG", entity(si->smu)->name);
return;
}
logcommand(si, CMDLOG_SET, "SET:PRIVMSG:OFF");
si->smu->flags &= ~MU_USE_PRIVMSG;
command_success_nodata(si, _("The \2%s\2 flag has been removed for \2%s\2."), "PRIVMSG", entity(si->smu)->name);
add_history_entry_setting(si->smu, si->smu, "PRIVMSG", "OFF");
return;
}
else
{
command_fail(si, fault_badparams, STR_INVALID_PARAMS, "PRIVMSG");
return;
}
}
command_t ns_set_privmsg = { "PRIVMSG", N_("Uses private messages instead of notices if enabled."), AC_NONE, 1, ns_cmd_set_privmsg, { .path = "nickserv/set_privmsg" } };
static bool uses_privmsg(const mynick_t *mn, const void *arg)
{
myuser_t *mu = mn->owner;
return (mu->flags & MU_USE_PRIVMSG) == MU_USE_PRIVMSG;
}
static bool account_uses_privmsg(myuser_t *mu, const void *arg)
{
return (mu->flags & MU_USE_PRIVMSG) == MU_USE_PRIVMSG;
}
void _modinit(module_t *m)
{
MODULE_TRY_REQUEST_SYMBOL(m, ns_set_cmdtree, "nickserv/set_core", "ns_set_cmdtree");
if (module_request("nickserv/main"))
add_history_entry_setting = module_locate_symbol("nickserv/main", "add_history_entry_setting");
command_add(&ns_set_privmsg, *ns_set_cmdtree);
use_privmsg++;
use_nslist_main_symbols(m);
static list_param_t use_privmsg;
use_privmsg.opttype = OPT_BOOL;
use_privmsg.is_match = uses_privmsg;
static list_param_account_t account_use_privmsg;
account_use_privmsg.opttype = OPT_BOOL;
account_use_privmsg.is_match = account_uses_privmsg;
list_register("use-privmsg", &use_privmsg);
list_register("use_privmsg", &use_privmsg);
list_account_register("use-privmsg", &account_use_privmsg);
list_account_register("use_privmsg", &account_use_privmsg);
}
void _moddeinit(module_unload_intent_t intent)
{
command_delete(&ns_set_privmsg, *ns_set_cmdtree);
use_privmsg--;
list_unregister("use-privmsg");
list_unregister("use_privmsg");
list_account_unregister("use-privmsg");
list_account_unregister("use_privmsg");
}
/* 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
*/
|