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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
#include "module.h"
/* Original module: cs_appendtopic by SGR
*
* Included in the Anope module pack since 1.7.9
* Anope Coder: GeniusDex <geniusdex@anope.org>
*
* Send bug reports to the Anope Coder instead of the module
* author, because any changes since the inclusion into anope
* are not supported by the original author.
*/
#define AUTHOR "SGR"
#define VERSION "$Id$"
/* ------------------------------------------------------------
* Name: cs_appendtopic
* Author: SGR <Alex_SGR@ntlworld.com>
* Date: 31/08/2003
* ------------------------------------------------------------
*
* This module has no configurable options. For information on
* this module, load it and refer to /ChanServ APPENDTOPIC HELP
*
* Thanks to dengel, Rob and Certus for all there support.
* Especially Rob, who always manages to show me where I have
* not allocated any memory. Even if it takes a few weeks of
* pestering to get him to look at it.
*
* ------------------------------------------------------------
*/
/* ---------------------------------------------------------------------- */
/* DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING */
/* ---------------------------------------------------------------------- */
#define LNG_NUM_STRINGS 3
#define LNG_CHAN_HELP 0
#define LNG_CHAN_HELP_APPENDTOPIC 1
#define LNG_APPENDTOPIC_SYNTAX 2
int my_cs_appendtopic(User * u);
void my_cs_help(User * u);
int my_cs_help_appendtopic(User * u);
void my_add_languages(void);
int AnopeInit(int argc, char **argv)
{
Command *c;
int status;
moduleAddAuthor(AUTHOR);
moduleAddVersion(VERSION);
moduleSetType(SUPPORTED);
c = createCommand("APPENDTOPIC", my_cs_appendtopic, NULL, -1, -1, -1,
-1, -1);
if ((status = moduleAddCommand(CHANSERV, c, MOD_HEAD))) {
alog("[cs_appendtopic] Unable to create APPENDTOPIC command: %d",
status);
return MOD_STOP;
}
moduleAddHelp(c, my_cs_help_appendtopic);
moduleSetChanHelp(my_cs_help);
my_add_languages();
alog("[cs_appendtopic] Loaded succesfully");
return MOD_CONT;
}
void AnopeFini(void)
{
alog("[cs_appendtopic] Unloaded succefully");
}
void my_cs_help(User * u)
{
moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP);
}
int my_cs_help_appendtopic(User * u)
{
moduleNoticeLang(s_ChanServ, u, LNG_APPENDTOPIC_SYNTAX);
notice(s_ChanServ, u->nick, " ");
moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP_APPENDTOPIC);
return MOD_STOP;
}
int my_cs_appendtopic(User * u)
{
char *cur_buffer;
char *chan;
char *newtopic;
char topic[1024];
Channel *c;
ChannelInfo *ci;
cur_buffer = moduleGetLastBuffer();
chan = myStrGetToken(cur_buffer, ' ', 0);
newtopic = myStrGetTokenRemainder(cur_buffer, ' ', 1);
if (!chan || !newtopic) {
moduleNoticeLang(s_ChanServ, u, LNG_APPENDTOPIC_SYNTAX);
} else if (!(c = findchan(chan))) {
notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
} else if (!(ci = c->ci)) {
notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
} else if (ci->flags & CI_VERBOTEN) {
notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
} else if (!is_services_admin(u) && !check_access(u, ci, CA_TOPIC)) {
notice_lang(s_ChanServ, u, PERMISSION_DENIED);
} else {
if (ci->last_topic) {
snprintf(topic, sizeof(topic), "%s %s", ci->last_topic,
newtopic);
free(ci->last_topic);
} else {
strscpy(topic, newtopic, sizeof(topic));
}
ci->last_topic = topic ? sstrdup(topic) : NULL;
strscpy(ci->last_topic_setter, u->nick, NICKMAX);
ci->last_topic_time = time(NULL);
if (c->topic)
free(c->topic);
c->topic = topic ? sstrdup(topic) : NULL;
strscpy(c->topic_setter, u->nick, NICKMAX);
if (ircd->topictsbackward)
c->topic_time = c->topic_time - 1;
else
c->topic_time = ci->last_topic_time;
if (is_services_admin(u) && !check_access(u, ci, CA_TOPIC))
alog("%s: %s!%s@%s changed topic of %s as services admin.",
s_ChanServ, u->nick, u->username, u->host, c->name);
if (ircd->join2set) {
if (whosends(ci) == s_ChanServ) {
anope_cmd_join(s_ChanServ, c->name, time(NULL));
anope_cmd_mode(NULL, c->name, "+o %s", s_ChanServ);
}
}
anope_cmd_topic(whosends(ci), c->name, u->nick, topic ? topic : "",
c->topic_time);
if (ircd->join2set) {
if (whosends(ci) == s_ChanServ) {
anope_cmd_part(s_ChanServ, c->name, NULL);
}
}
}
return MOD_CONT;
}
void my_add_languages(void)
{
/* English (US) */
char *langtable_en_us[] = {
/* LNG_CHAN_HELP */
" APPENDTOPIC Add text to a channels topic",
/* LNG_CHAN_HELP_APPENDTOPIC */
"This command allows users to append text to a currently set\n"
"channel topic. When TOPICLOCK is on, the topic is updated and\n"
"the new, updated topic is locked.",
/* LNG_APPENDTOPIC_SYNTAX */
"Syntax: APPENDTOPIC channel text\n"
};
/* Dutch */
char *langtable_nl[] = {
/* LNG_CHAN_HELP */
" APPENDTOPIC Voeg tekst aan een kanaal onderwerp toe",
/* LNG_CHAN_HELP_APPENDTOPIC */
"Dit command stelt gebruikers in staat om text toe te voegen\n"
"achter het huidige onderwerp van een kanaal. Als TOPICLOCK aan\n"
"staat, zal het onderwerp worden bijgewerkt en zal het nieuwe,\n"
"bijgewerkte topic worden geforceerd.",
/* LNG_APPENDTOPIC_SYNTAX */
"Gebruik: APPENDTOPIC kanaal tekst\n"
};
char *langtable_de[] = {
/* LNG_CHAN_HELP */
" APPENDTOPIC Fühgt ein Text zu ein Channel Topic ein",
/* LNG_CHAN_HELP_APPENDTOPIC */
"Das befehl erlaubt User ein Text zu den vorhandenen Channel Topic\n"
"hinzu zu fühgen. Wenn TOPICLOCK an ist, wird der Topic aktualisiert\n"
"und der neue aktualisierte Topic wird locked.",
/* LNG_APPENDTOPIC_SYNTAX */
"Syntax: APPENDTOPIC Channel Text\n"
};
moduleInsertLanguage(LANG_EN_US, LNG_NUM_STRINGS, langtable_en_us);
moduleInsertLanguage(LANG_NL, LNG_NUM_STRINGS, langtable_nl);
moduleInsertLanguage(LANG_DE, LNG_NUM_STRINGS, langtable_de);
}
/* EOF */
|