botserv/set_saycaller: (optionally) give caller-nick
functionality is not active until enabled individually per channel.
(Fixes #487)
Austin Ellis
7 years ago
0 | Help for SET SAYCALLER: | |
1 | ||
2 | This option when turned on will prefix any &nick& SAY | |
3 | or ACTION command messages with the caller's nickname. | |
4 | ||
5 | Syntax: SET <channel> SAYCALLER {ON|OFF} | |
6 | ||
7 | Examples: | |
8 | /msg &nick& SET #ChatZone SAYCALLER ON | |
9 | /msg &nick& SET #ChatZone SAYCALLER OFF |
0 | # Copyright (c) 2016 Austin Ellis | |
0 | 1 | # Copyright (c) 2003-2004 E. Will et al. |
1 | 2 | # Rights to this code are documented in doc/LICENSE. |
2 | 3 | # |
17 | 18 | set_fantasy.c \ |
18 | 19 | set_nobot.c \ |
19 | 20 | set_private.c \ |
21 | set_saycaller.c \ | |
20 | 22 | |
21 | 23 | include ../../extra.mk |
22 | 24 | include ../../buildsys.mk |
0 | 0 | /* |
1 | * Copyright (c) 2016 Austin Ellis | |
1 | 2 | * Copyright (c) 2009 Celestin, et al. |
2 | 3 | * Rights to this code are as documented in doc/LICENSE. |
3 | 4 | * |
12 | 13 | ( |
13 | 14 | "botserv/bottalk", false, _modinit, _moddeinit, |
14 | 15 | PACKAGE_STRING, |
15 | "Rizon Development Group <http://dev.rizon.net>" | |
16 | VENDOR_STRING | |
16 | 17 | ); |
17 | 18 | |
18 | 19 | static void bs_cmd_say(sourceinfo_t *si, int parc, char *parv[]); |
37 | 38 | { |
38 | 39 | char *channel = parv[0]; |
39 | 40 | char *message = parv[1]; |
41 | char saybuf[BUFSIZE]; | |
40 | 42 | metadata_t *bs; |
41 | 43 | user_t *bot; |
42 | 44 | |
67 | 69 | command_fail(si, fault_noprivs, _("You are not authorized to perform this operation.")); |
68 | 70 | return; |
69 | 71 | } |
72 | ||
73 | if (metadata_find(mc, "private:frozen:freezer")) | |
74 | { | |
75 | command_fail(si, fault_noprivs, _("\2%s\2 is frozen."), mc->name); | |
76 | return; | |
77 | } | |
70 | 78 | |
71 | 79 | if ((bs = metadata_find(mc, "private:botserv:bot-assigned")) != NULL) |
72 | 80 | bot = user_find_named(bs->value); |
78 | 86 | return; |
79 | 87 | } |
80 | 88 | |
89 | if (metadata_find(mc, "private:botserv:saycaller")) | |
90 | { | |
91 | snprintf(saybuf, BUFSIZE, "%s", get_source_name(si)); | |
92 | msg(bot->nick, channel, "(%s) %s", saybuf, message); | |
93 | logcommand(si, CMDLOG_DO, "SAY:\2%s\2: \2%s\2", channel, message); | |
94 | } | |
95 | else | |
96 | { | |
97 | ||
81 | 98 | msg(bot->nick, channel, "%s", message); |
82 | 99 | logcommand(si, CMDLOG_DO, "SAY:\2%s\2: \2%s\2", channel, message); |
100 | } | |
83 | 101 | } |
84 | 102 | |
85 | 103 | static void bs_cmd_act(sourceinfo_t *si, int parc, char *parv[]) |
86 | 104 | { |
87 | 105 | char *channel = parv[0]; |
88 | 106 | char *message = parv[1]; |
107 | char actbuf[BUFSIZE]; | |
89 | 108 | metadata_t *bs; |
90 | 109 | user_t *bot; |
91 | 110 | |
116 | 135 | command_fail(si, fault_noprivs, _("You are not authorized to perform this operation.")); |
117 | 136 | return; |
118 | 137 | } |
138 | ||
139 | if (metadata_find(mc, "private:frozen:freezer")) | |
140 | { | |
141 | command_fail(si, fault_noprivs, _("\2%s\2 is frozen."), mc->name); | |
142 | return; | |
143 | } | |
119 | 144 | |
120 | 145 | if ((bs = metadata_find(mc, "private:botserv:bot-assigned")) != NULL) |
121 | 146 | bot = user_find_named(bs->value); |
126 | 151 | command_fail(si, fault_nosuch_key, _("\2%s\2 does not have a bot assigned."), mc->name); |
127 | 152 | return; |
128 | 153 | } |
154 | if (metadata_find(mc, "private:botserv:saycaller")) | |
155 | { | |
156 | snprintf(actbuf, BUFSIZE, "%s", get_source_name(si)); | |
157 | msg(bot->nick, channel, "\001ACTION (%s) %s\001", actbuf, message); | |
158 | logcommand(si, CMDLOG_DO, "ACT:\2%s\2: \2%s\2", channel, message); | |
159 | } | |
160 | else | |
161 | { | |
129 | 162 | |
130 | 163 | msg(bot->nick, channel, "\001ACTION %s\001", message); |
131 | 164 | logcommand(si, CMDLOG_DO, "ACT:\2%s\2: \2%s\2", channel, message); |
165 | } | |
132 | 166 | } |
133 | 167 | |
134 | 168 | /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs |
13 | 13 | ( |
14 | 14 | "botserv/set", false, _modinit, _moddeinit, |
15 | 15 | PACKAGE_STRING, |
16 | "Rizon Development Group <http://dev.rizon.net>" | |
17 | 16 | ); |
18 | 17 | |
19 | 18 | void _modinit(module_t *m) |
23 | 22 | MODULE_TRY_REQUEST_DEPENDENCY(m, "botserv/set_fantasy"); |
24 | 23 | MODULE_TRY_REQUEST_DEPENDENCY(m, "botserv/set_nobot"); |
25 | 24 | MODULE_TRY_REQUEST_DEPENDENCY(m, "botserv/set_private"); |
25 | MODULE_TRY_REQUEST_DEPENDENCY(m, "botserv/set_saycaller"); | |
26 | 26 | |
27 | 27 | } |
28 | 28 |
0 | /* | |
1 | * Copyright (c) 2016 Austin Ellis | |
2 | * Rights to this code are as documented in doc/LICENSE. | |
3 | * | |
4 | * Enable say/act caller ID. | |
5 | * | |
6 | */ | |
7 | ||
8 | #include "atheme.h" | |
9 | #include "uplink.h" | |
10 | ||
11 | DECLARE_MODULE_V1 | |
12 | ( | |
13 | "botserv/set_saycaller", false, _modinit, _moddeinit, | |
14 | PACKAGE_STRING, | |
15 | VENDOR_STRING | |
16 | ); | |
17 | ||
18 | mowgli_patricia_t **bs_set_cmdtree; | |
19 | ||
20 | static void bs_cmd_set_saycaller(sourceinfo_t *si, int parc, char *parv[]); | |
21 | ||
22 | command_t bs_set_saycaller = { "SAYCALLER", N_("Enable Caller-ID on BotServ actions or messages."), AC_AUTHENTICATED, 2, bs_cmd_set_saycaller, { .path = "botserv/set_saycaller" } }; | |
23 | ||
24 | void _modinit(module_t *m) | |
25 | { | |
26 | MODULE_TRY_REQUEST_SYMBOL(m, bs_set_cmdtree, "botserv/set_core", "bs_set_cmdtree"); | |
27 | ||
28 | command_add(&bs_set_saycaller, *bs_set_cmdtree); | |
29 | ||
30 | } | |
31 | ||
32 | void _moddeinit(module_unload_intent_t intent) | |
33 | { | |
34 | command_delete(&bs_set_saycaller, *bs_set_cmdtree); | |
35 | ||
36 | } | |
37 | ||
38 | static void bs_cmd_set_saycaller(sourceinfo_t *si, int parc, char *parv[]) | |
39 | { | |
40 | char *channel = parv[0]; | |
41 | char *option = parv[1]; | |
42 | mychan_t *mc; | |
43 | metadata_t *md; | |
44 | ||
45 | if (parc < 2 || !channel || !option) | |
46 | { | |
47 | command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "SET SAYCALLER"); | |
48 | command_fail(si, fault_needmoreparams, _("Syntax: SET <#channel> SAYCALLER {ON|OFF}")); | |
49 | return; | |
50 | } | |
51 | ||
52 | mc = mychan_find(channel); | |
53 | if (!mc) | |
54 | { | |
55 | command_fail(si, fault_nosuch_target, _("Channel \2%s\2 is not registered."), channel); | |
56 | return; | |
57 | } | |
58 | ||
59 | if (!chanacs_source_has_flag(mc, si, CA_SET)) | |
60 | { | |
61 | command_fail(si, fault_noprivs, _("You are not authorized to perform this operation.")); | |
62 | return; | |
63 | } | |
64 | ||
65 | if (metadata_find(mc, "private:frozen:freezer")) | |
66 | { | |
67 | command_fail(si, fault_noprivs, _("\2%s\2 is frozen."), mc->name); | |
68 | return; | |
69 | } | |
70 | ||
71 | if (!irccasecmp(option, "ON")) | |
72 | { | |
73 | if ((md = metadata_find(mc, "private:botserv:bot-assigned")) != NULL) | |
74 | metadata_add(mc, "private:botserv:saycaller", md->value); | |
75 | ||
76 | logcommand(si, CMDLOG_SET, "SET:SAYCALLER:ON: \2%s\2", mc->name); | |
77 | ||
78 | command_success_nodata(si, _("Say Caller is now \2ON\2 on channel %s."), mc->name); | |
79 | } | |
80 | else if(!irccasecmp(option, "OFF")) | |
81 | { | |
82 | metadata_delete(mc, "private:botserv:saycaller"); | |
83 | logcommand(si, CMDLOG_SET, "SET:SAYCALLER:OFF: \2%s\2", mc->name); | |
84 | command_success_nodata(si, _("Say Caller is now \2OFF\2 on channel %s."), mc->name); | |
85 | } | |
86 | else | |
87 | { | |
88 | command_fail(si, fault_badparams, STR_INVALID_PARAMS, "SET SAYCALLER"); | |
89 | command_fail(si, fault_badparams, _("Syntax: SET <#channel> SAYCALLER {ON|OFF}")); | |
90 | } | |
91 | } | |
92 |