]>
Commit | Line | Data |
---|---|---|
8eb15d2d | 1 | diff -burNp eggdrop1.6.19/src/chan.h eggdrop1.6.19.new/src/chan.h |
2 | --- eggdrop1.6.19/src/chan.h 2008-02-16 22:41:03.000000000 +0100 | |
3 | +++ eggdrop1.6.19.new/src/chan.h 2008-09-22 11:27:30.636306556 +0200 | |
4 | @@ -191,6 +191,7 @@ struct chanset_t { | |
1338a78c AG |
5 | int mode_mns_prot; /* modes to reject */ |
6 | int limit_prot; /* desired limit */ | |
7 | char key_prot[121]; /* desired password */ | |
8 | + char topic_prot[501]; /* desired topic */ | |
9 | char pls[21]; /* positive mode changes */ | |
10 | char mns[21]; /* negative mode changes */ | |
11 | char *key; /* new key to set */ | |
8eb15d2d | 12 | diff -burNp eggdrop1.6.19/src/chanprog.c eggdrop1.6.19.new/src/chanprog.c |
13 | --- eggdrop1.6.19/src/chanprog.c 2008-02-16 22:41:03.000000000 +0100 | |
14 | +++ eggdrop1.6.19.new/src/chanprog.c 2008-09-22 11:30:50.744325464 +0200 | |
15 | @@ -690,3 +690,24 @@ int isowner(char *name) | |
9f896ea6 AG |
16 | |
17 | return 0; | |
1338a78c AG |
18 | } |
19 | + | |
20 | +/* If we have a protected topic and the bot is opped, halfoped, | |
21 | + * or the channel is -t, change the topic. (Sup 11May2001) | |
8eb15d2d | 22 | +*/ |
1338a78c AG |
23 | +void check_topic(struct chanset_t *chan) |
24 | +{ | |
25 | + memberlist *m = NULL; | |
26 | + | |
27 | + if (chan->topic_prot[0]) { | |
28 | + m = ismember(chan, botname); | |
29 | + if (!m) | |
30 | + return; | |
31 | + if (chan->channel.topic) { | |
32 | + if (!egg_strcasecmp(chan->topic_prot, chan->channel.topic)) | |
33 | + return; | |
34 | + } | |
35 | + if (chan_hasop(m) || !channel_optopic(chan) || chan_hashalfop(m)) | |
36 | + dprintf(DP_SERVER, "TOPIC %s :%s\n", chan->name, chan->topic_prot); | |
37 | + } | |
38 | +} | |
8eb15d2d | 39 | + |
40 | diff -burNp eggdrop1.6.19/src/mod/channels.mod/channels.c eggdrop1.6.19.new/src/mod/channels.mod/channels.c | |
41 | --- eggdrop1.6.19/src/mod/channels.mod/channels.c 2008-02-16 22:41:06.000000000 +0100 | |
42 | +++ eggdrop1.6.19.new/src/mod/channels.mod/channels.c 2008-09-22 11:34:55.161533902 +0200 | |
43 | @@ -385,6 +385,7 @@ static void write_channels() | |
1338a78c AG |
44 | FILE *f; |
45 | char s[121], w[1024], w2[1024], name[163]; | |
46 | char need1[242], need2[242], need3[242], need4[242], need5[242]; | |
47 | + char topic[1002]; | |
48 | struct chanset_t *chan; | |
49 | struct udef_struct *ul; | |
50 | ||
8eb15d2d | 51 | @@ -405,6 +406,7 @@ static void write_channels() |
1338a78c AG |
52 | convert_element(chan->dname, name); |
53 | get_mode_protect(chan, w); | |
54 | convert_element(w, w2); | |
eef4670e | 55 | + convert_element(chan->topic_prot, topic); |
1338a78c AG |
56 | convert_element(chan->need_op, need1); |
57 | convert_element(chan->need_invite, need2); | |
58 | convert_element(chan->need_key, need3); | |
8eb15d2d | 59 | @@ -412,7 +414,7 @@ static void write_channels() |
1338a78c | 60 | convert_element(chan->need_limit, need5); |
9f896ea6 | 61 | /* Do not indent me (adds extra spaces to chan file). */ |
1338a78c | 62 | fprintf(f, |
9f896ea6 AG |
63 | -"channel %s %s%schanmode %s idle-kick %d stopnethack-mode %d revenge-mode %d \ |
64 | +"channel %s %s%schanmode %s topic %s idle-kick %d stopnethack-mode %d revenge-mode %d \ | |
65 | need-op %s need-invite %s need-key %s need-unban %s need-limit %s \ | |
66 | flood-chan %d:%d flood-ctcp %d:%d flood-join %d:%d flood-kick %d:%d \ | |
67 | flood-deop %d:%d flood-nick %d:%d aop-delay %d:%d ban-time %d exempt-time %d \ | |
8eb15d2d | 68 | @@ -422,7 +424,7 @@ invite-time %d %cenforcebans %cdynamicba |
9f896ea6 AG |
69 | %cseen %cinactive %cdynamicexempts %cuserexempts %cdynamicinvites \ |
70 | %cuserinvites %cnodesynch ", | |
1338a78c AG |
71 | channel_static(chan) ? "set" : "add", name, channel_static(chan) ? |
72 | - " " : " { ", w2, chan->idle_kick, chan->stopnethack_mode, | |
8eb15d2d | 73 | + " " : " { ", w2, topic, chan->idle_kick, chan->stopnethack_mode, |
1338a78c AG |
74 | chan->revenge_mode, need1, need2, need3, need4, need5, |
75 | chan->flood_pub_thr, chan->flood_pub_time, | |
76 | chan->flood_ctcp_thr, chan->flood_ctcp_time, | |
8eb15d2d | 77 | diff -burNp eggdrop1.6.19/src/mod/channels.mod/cmdschan.c eggdrop1.6.19.new/src/mod/channels.mod/cmdschan.c |
78 | --- eggdrop1.6.19/src/mod/channels.mod/cmdschan.c 2008-02-16 22:41:07.000000000 +0100 | |
79 | +++ eggdrop1.6.19.new/src/mod/channels.mod/cmdschan.c 2008-09-22 11:37:38.571477034 +0200 | |
80 | @@ -1269,6 +1269,7 @@ static void cmd_chaninfo(struct userrec | |
1338a78c AG |
81 | channel_static(chan) ? "static" : "dynamic", chan->dname); |
82 | get_mode_protect(chan, work); | |
83 | dprintf(idx, "Protect modes (chanmode): %s\n", work[0] ? work : "None"); | |
84 | + dprintf(idx, "Protect topic: %s\n", chan->topic_prot[0] ? chan->topic_prot : "None"); | |
85 | if (chan->idle_kick) | |
86 | dprintf(idx, "Idle Kick after (idle-kick): %d\n", chan->idle_kick); | |
87 | else | |
8eb15d2d | 88 | diff -burNp eggdrop1.6.19/src/mod/channels.mod/help/chaninfo.help eggdrop1.6.19.new/src/mod/channels.mod/help/chaninfo.help |
89 | --- eggdrop1.6.19/src/mod/channels.mod/help/chaninfo.help 2003-02-02 05:20:44.000000000 +0100 | |
90 | +++ eggdrop1.6.19.new/src/mod/channels.mod/help/chaninfo.help 2008-09-22 11:42:29.504962817 +0200 | |
1338a78c AG |
91 | @@ -4,6 +4,7 @@ |
92 | It shows any of the following: | |
93 | %bchanmode%b These modes are enforced on the channel. Both + and - | |
94 | modes can be enforced. | |
8eb15d2d | 95 | + %btopic%b which topic is enforced on the channel |
1338a78c AG |
96 | %bidle-kick%b Kick idle users that are not +f or above on the channel |
97 | after how many minutes (set this to 0 to disable). | |
98 | %{+n} | |
8eb15d2d | 99 | diff -burNp eggdrop1.6.19/src/mod/channels.mod/tclchan.c eggdrop1.6.19.new/src/mod/channels.mod/tclchan.c |
100 | --- eggdrop1.6.19/src/mod/channels.mod/tclchan.c 2008-02-16 22:41:07.000000000 +0100 | |
101 | +++ eggdrop1.6.19.new/src/mod/channels.mod/tclchan.c 2008-09-22 11:46:12.888320583 +0200 | |
102 | @@ -1223,6 +1223,15 @@ static int tcl_channel_modify(Tcl_Interp | |
1338a78c AG |
103 | return TCL_ERROR; |
104 | } | |
105 | chan->invite_time = atoi(item[i]); | |
106 | + } else if (!strcmp(item[i], "topic")) { | |
107 | + i++; | |
108 | + if (i >= items) { | |
109 | + if (irp) | |
110 | + Tcl_AppendResult(irp, "channel topic needs argument", NULL); | |
111 | + return TCL_ERROR; | |
112 | + } | |
113 | + strncpyz(chan->topic_prot, item[i], sizeof(chan->topic_prot)); | |
114 | + check_topic(chan); | |
115 | } else if (!strcmp(item[i], "+enforcebans")) | |
116 | chan->status |= CHAN_ENFORCEBANS; | |
117 | else if (!strcmp(item[i], "-enforcebans")) | |
8eb15d2d | 118 | diff -burNp eggdrop1.6.19/src/mod/irc.mod/chan.c eggdrop1.6.19.new/src/mod/irc.mod/chan.c |
119 | --- eggdrop1.6.19/src/mod/irc.mod/chan.c 2008-02-16 22:41:09.000000000 +0100 | |
120 | +++ eggdrop1.6.19.new/src/mod/irc.mod/chan.c 2008-09-22 11:51:07.921436628 +0200 | |
121 | @@ -1513,12 +1513,14 @@ static int gottopic(char *from, char *ms | |
1338a78c AG |
122 | memberlist *m; |
123 | struct chanset_t *chan; | |
124 | struct userrec *u; | |
125 | + struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0}; | |
126 | ||
127 | chname = newsplit(&msg); | |
128 | fixcolon(msg); | |
129 | u = get_user_by_host(from); | |
130 | nick = splitnick(&from); | |
131 | chan = findchan(chname); | |
132 | + get_user_flagrec(u, &fr, chname); | |
133 | if (chan) { | |
134 | putlog(LOG_JOIN, chan->dname, "Topic changed on %s by %s!%s: %s", | |
135 | chan->dname, nick, from, msg); | |
8eb15d2d | 136 | @@ -1527,6 +1529,8 @@ static int gottopic(char *from, char *ms |
1338a78c AG |
137 | m->last = now; |
138 | set_topic(chan, msg); | |
139 | check_tcl_topc(nick, from, u, chan->dname, msg); | |
140 | + if (egg_strcasecmp(botname, nick) && !glob_master(fr) && !chan_master(fr)) | |
141 | + check_topic(chan); | |
142 | } | |
143 | return 0; | |
144 | } | |
8eb15d2d | 145 | @@ -1545,6 +1549,7 @@ static int got331(char *from, char *msg) |
1338a78c AG |
146 | if (chan) { |
147 | set_topic(chan, NULL); | |
148 | check_tcl_topc("*", "*", NULL, chan->dname, ""); | |
149 | + check_topic(chan); | |
150 | } | |
151 | return 0; | |
152 | } | |
8eb15d2d | 153 | @@ -1564,6 +1569,7 @@ static int got332(char *from, char *msg) |
1338a78c AG |
154 | fixcolon(msg); |
155 | set_topic(chan, msg); | |
156 | check_tcl_topc("*", "*", NULL, chan->dname, msg); | |
157 | + check_topic(chan); | |
158 | } | |
159 | return 0; | |
160 | } | |
8eb15d2d | 161 | diff -burNp eggdrop1.6.19/src/mod/irc.mod/cmdsirc.c eggdrop1.6.19.new/src/mod/irc.mod/cmdsirc.c |
162 | --- eggdrop1.6.19/src/mod/irc.mod/cmdsirc.c 2008-02-16 22:41:09.000000000 +0100 | |
163 | +++ eggdrop1.6.19.new/src/mod/irc.mod/cmdsirc.c 2008-09-22 11:55:02.514726004 +0200 | |
164 | @@ -898,6 +898,7 @@ static void cmd_channel(struct userrec * | |
1338a78c AG |
165 | static void cmd_topic(struct userrec *u, int idx, char *par) |
166 | { | |
167 | struct chanset_t *chan; | |
168 | + struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0}; | |
169 | ||
170 | if (par[0] && (strchr(CHANMETA, par[0]) != NULL)) { | |
171 | char *chname = newsplit(&par); | |
8eb15d2d | 172 | @@ -923,6 +924,13 @@ static void cmd_topic(struct userrec *u, |
1338a78c AG |
173 | dprintf(idx, "I'm not a channel op or halfop on %s and the channel is " |
174 | "+t.\n", chan->dname); | |
175 | else { | |
176 | + if (chan->topic_prot[0]) { | |
177 | + get_user_flagrec(u, &fr, chan->dname); | |
178 | + if (!glob_master(fr) && !chan_master(fr)) { | |
8eb15d2d | 179 | + dprintf(idx, "The topic of %s is protected.\n", chan->dname); |
180 | + return; | |
1338a78c AG |
181 | + } |
182 | + } | |
183 | dprintf(DP_SERVER, "TOPIC %s :%s\n", chan->name, par); | |
184 | dprintf(idx, "Changing topic...\n"); | |
185 | putlog(LOG_CMDS, "*", "#%s# (%s) topic %s", dcc[idx].nick, | |
8eb15d2d | 186 | diff -burNp eggdrop1.6.19/src/mod/irc.mod/mode.c eggdrop1.6.19.new/src/mod/irc.mod/mode.c |
187 | --- eggdrop1.6.19/src/mod/irc.mod/mode.c 2008-02-16 22:41:09.000000000 +0100 | |
188 | +++ eggdrop1.6.19.new/src/mod/irc.mod/mode.c 2008-09-22 12:00:05.134685721 +0200 | |
189 | @@ -460,8 +460,10 @@ static void got_op(struct chanset_t *cha | |
1338a78c AG |
190 | } |
191 | } | |
192 | m->flags |= WASOP; | |
193 | - if (check_chan) | |
194 | + if (check_chan) { | |
195 | recheck_channel(chan, 1); | |
196 | + check_topic(chan); | |
197 | + } | |
198 | } | |
199 | ||
200 | static void got_halfop(struct chanset_t *chan, char *nick, char *from, | |
8eb15d2d | 201 | @@ -549,8 +551,10 @@ static void got_halfop(struct chanset_t |
1338a78c AG |
202 | } |
203 | } | |
204 | m->flags |= WASHALFOP; | |
205 | - if (check_chan) | |
206 | + if (check_chan) { | |
207 | recheck_channel(chan, 1); | |
208 | + check_topic(chan); | |
209 | + } | |
210 | } | |
211 | ||
212 | static void got_deop(struct chanset_t *chan, char *nick, char *from, | |
8eb15d2d | 213 | @@ -1246,6 +1250,8 @@ static int gotmode(char *from, char *ori |
1338a78c AG |
214 | (chan->mode_mns_prot & todo))) |
215 | add_mode(chan, ms2[0] == '+' ? '-' : '+', *chg, ""); | |
216 | } | |
8eb15d2d | 217 | + if ((ms2[0] == '-') && ((*chg == 't') || (*chg == 'h'))) |
1338a78c AG |
218 | + check_topic(chan); |
219 | } | |
220 | chg++; | |
221 | } | |
8eb15d2d | 222 | diff -burNp eggdrop1.6.19/src/mod/module.h eggdrop1.6.19.new/src/mod/module.h |
223 | --- eggdrop1.6.19/src/mod/module.h 2008-02-16 22:41:06.000000000 +0100 | |
224 | +++ eggdrop1.6.19.new/src/mod/module.h 2008-09-22 12:01:11.964804368 +0200 | |
9f896ea6 | 225 | @@ -361,7 +361,7 @@ |
1338a78c AG |
226 | #define rem_tcl_coups ((void (*) (tcl_coups *))global[210]) |
227 | #define botname ((char *)(global[211])) | |
228 | /* 212 - 215 */ | |
229 | -/* 212: remove_gunk() -- UNUSED (drummer) */ | |
230 | +#define check_topic ((void (*)(struct chanset_t *))global[212]) | |
231 | #define check_tcl_chjn ((void (*) (const char *,const char *,int,char,int,const char *))global[213]) | |
232 | #define sanitycheck_dcc ((int (*)(char *, char *, char *, char *))global[214]) | |
233 | #define isowner ((int (*)(char *))global[215]) | |
8eb15d2d | 234 | diff -burNp eggdrop1.6.19/src/modules.c eggdrop1.6.19.new/src/modules.c |
235 | --- eggdrop1.6.19/src/modules.c 2008-02-16 22:41:04.000000000 +0100 | |
236 | +++ eggdrop1.6.19.new/src/modules.c 2008-09-22 12:09:57.119525901 +0200 | |
237 | @@ -461,7 +461,7 @@ Function global_table[] = { | |
1338a78c AG |
238 | (Function) rem_tcl_coups, |
239 | (Function) botname, | |
240 | /* 212 - 215 */ | |
241 | - (Function) 0, /* remove_gunk() -- UNUSED! (drummer) */ | |
242 | + (Function) check_topic, | |
243 | (Function) check_tcl_chjn, | |
244 | (Function) sanitycheck_dcc, | |
245 | (Function) isowner, | |
8eb15d2d | 246 | diff -burNp eggdrop1.6.19/src/patch.h eggdrop1.6.19.new/src/patch.h |
247 | --- eggdrop1.6.19/src/patch.h 2008-04-19 06:21:20.000000000 +0200 | |
248 | +++ eggdrop1.6.19.new/src/patch.h 2008-09-22 12:11:00.141439071 +0200 | |
1338a78c AG |
249 | @@ -36,7 +36,7 @@ |
250 | * | |
251 | * | |
252 | */ | |
253 | -/* PATCH GOES HERE */ | |
254 | +patch("topicprot"); | |
255 | /* | |
256 | * | |
257 | * | |
8eb15d2d | 258 | diff -burNp eggdrop1.6.19/src/proto.h eggdrop1.6.19.new/src/proto.h |
259 | --- eggdrop1.6.19/src/proto.h 2008-02-16 22:41:04.000000000 +0100 | |
260 | +++ eggdrop1.6.19.new/src/proto.h 2008-09-22 12:12:19.684612158 +0200 | |
261 | @@ -114,6 +114,7 @@ void check_timers(); | |
1338a78c AG |
262 | void set_chanlist(const char *host, struct userrec *rec); |
263 | void clear_chanlist(void); | |
264 | void clear_chanlist_member(const char *nick); | |
265 | +void check_topic(struct chanset_t *); | |
266 | ||
267 | /* cmds.c */ | |
268 | int check_dcc_attrs(struct userrec *, int); |