/[cvs]/eggdrop1.6/scripts/getops.tcl
ViewVC logotype

Contents of /eggdrop1.6/scripts/getops.tcl

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Tue Jun 20 20:37:31 2000 UTC (19 years, 5 months ago) by fabian
Branch: MAIN
File MIME type: application/x-tcl
getops_userinfo_fix patch

1
2 # Getops 2.2e
3
4 # $Id$
5
6 # This script is used for bots to request and give ops to each other.
7 # For this to work, you'll need:
8
9 # - Bots must be linked in a botnet
10 # - Every bot that should be ops on your channels must load this script
11 # - Add all bots you wanna op with this one using the .+bot nick address
12 # command. The "nick" should be exactly the botnet-nick of the other bot
13 # - Add the hostmasks that uniquely identify this bot on IRC
14 # - Add a global or channel +o flag on all bots to be opped
15 # - Do exactly the same on all other bots
16
17 # The security of this relies on the fact that the bot which wants to have
18 # ops must be 1) linked to the current botnet (which requires a password),
19 # 2) have an entry with +o on the bot that he wants ops from and 3) must match
20 # the hostmask that is stored on each bots userfile (so it is good to keep the
21 # hostmasks up-to-date).
22
23 # -----------------------------------------------------------------------------
24
25 # 2.2e by Fabian <fknittel@gmx.de>
26 # - added support for !channels (so-called ID-channels), using chandname2name
27 # functions. This makes it eggdrop 1.5 specific.
28
29 # 2.2d by brainsick <brnsck@mail.earthlink.net>
30 # - Undernet now handles keys differently. It no longer gives the key on a
31 # join, but instead gives it on an op, but eggdrop doesn't check for this.
32 # getops-2.2d should now handle this correctly. (This should be the final
33 # fix to the key problems.)
34
35 # 2.2c by Progfou (Jean Christophe ANDRE <progfou@rumiko.info.unicaen.fr>)
36 # - changed "Requested" to "Requesting" as it was a little confusing
37 # - corrected the "I am not on chan..." problem with key request
38 # (thanks to Kram |FL| and Gael for reporting it)
39 # - removed more unnecessary check
40
41 # 2.2b by Progfou (Jean Christophe ANDRE <progfou@rumiko.info.unicaen.fr>)
42 # - removed global +o in unknown bot test
43 # - removed unnecessary checks due to previous unknown bot test
44
45 # 2.2a by Progfou (Jean Christophe ANDRE <progfou@rumiko.info.unicaen.fr>)
46 # - removed Polish language!
47
48 # 2.2 by Cron (Arkadiusz Miskiewicz <misiek@zsz2.starachowice.pl>)
49 # - works good (tested on eggdrop 1.3.11)
50 # - asks from unknown (and bots without +bo) are ignored
51 # - all messages in Polish language
52 # - better response from script to users
53 # - fixed several bugs
54
55 # 2.1 by Ernst
56 # - asks for ops right after joining the channel: no wait anymore
57 # - sets "need-op/need-invite/etc" config right after joining dynamic channels
58 # - fixed "You aren't +o" being replied when other bot isn't even on channel
59 # - better response from bots, in case something went wrong
60 # (for example if bot is not recognized (hostmask) when asking for ops)
61 # - removed several no-more-used variables
62 # - added the information and description above
63
64 # 2.0.1 by beldin (1.3.x ONLY version)
65 # - actually, iso needed to be modded for 1.3 :P, and validchan is builtin
66 # and I'll tidy a couple of functions up to
67
68 # 2.0 by DarkDruid
69 # - It'll work with dynamic channels(dan is a dork for making it not..)
70 # - It will also only ask one bot at a time for ops so there won't be any more
71 # annoying mode floods, and it's more secure that way
72 # - I also took that annoying wallop and resynch stuff out :P
73 # - And I guess this will with with 1.3.x too
74
75 # Previously by The_O, dtM and poptix.
76
77 # -----------------------------------------------------------------------------
78
79 # [0/1] do you want GetOps to notice when some unknown (unauthorized) bot
80 # sends request to your bot
81 set go_bot_unknown 1
82
83 # [0/1] do you want your bot to request to be unbanned if it becomes banned?
84 set go_bot_unban 1
85
86 # [0/1] do you want GetOps to notice the channel if there are no ops?
87 set go_cycle 0
88
89 # set this to the notice txt for the above (go_cycle)
90 set go_cycle_msg "Please part the channel so the bots can cycle!"
91
92 # -----------------------------------------------------------------------------
93
94 set bns ""
95 proc gain_entrance {what chan} {
96 global botnick botname go_bot_unban go_cycle go_cycle_msg bns
97 switch -exact $what {
98 "limit" {
99 foreach bs [lbots] {
100 putbot $bs "gop limit $chan $botnick"
101 putlog "GetOps: Requesting limit raise from $bs on $chan."
102 }
103 }
104 "invite" {
105 foreach bs [lbots] {
106 putbot $bs "gop invite $chan $botnick"
107 putlog "GetOps: Requesting invite from $bs for $chan."
108 }
109 }
110 "unban" {
111 if {$go_bot_unban} {
112 foreach bs [lbots] {
113 putbot $bs "gop unban $chan $botname"
114 putlog "GetOps: Requesting unban on $chan from $bs."
115 }
116 }
117 }
118 "key" {
119 foreach bs [lbots] {
120 putbot $bs "gop key $chan $botnick"
121 putlog "GetOps: Requesting key on $chan from $bs."
122 }
123 }
124 "op" {
125 if {[hasops $chan]} {
126 set bot [getbot $chan]
127 if {$bot == ""} {
128 set bns ""
129 set bot [getbot $chan]
130 }
131 lappend bns "$bot"
132 if {$bot != ""} {
133 putbot $bot "gop op $chan $botnick"
134 putlog "GetOps: Requesting ops from $bot on $chan"
135 }
136 } {
137 if {$go_cycle} {
138 putserv "NOTICE [chandname2name $chan] :$go_cycle_msg"
139 }
140 }
141 }
142 }
143 }
144 proc hasops {chan} {
145 foreach user [chanlist $chan] {
146 if {[isop $user $chan]} {
147 return 1
148 }
149 }
150 return 0
151 }
152 proc getbot {chan} {
153 global bns
154 foreach bn [bots] {
155 if {[lsearch $bns $bn] < 0} {
156 if {([matchattr $bn o]) || ([matchattr $bn |o $chan])} {
157 if {([onchan [hand2nick $bn $chan] $chan]) && ([isop [hand2nick $bn $chan] $chan])} {
158 return $bn
159 break
160 }
161 }
162 }
163 }
164 }
165
166 proc botnet_request {bot com args} {
167 global botnick go_bot_unban go_bot_unknown
168 set args [lindex $args 0]
169 set subcom [lindex $args 0]
170 set chan [string tolower [lindex $args 1]]
171 set idchan [chandname2name $chan]
172 set nick [lindex $args 2]
173
174 if {[matchattr $bot b] == 0} {
175 if { $go_bot_unknown == 1} {
176 putlog "GetOps: Request ($subcom) from $bot - unknown bot (IGNORED)"
177 }
178 return 0
179 }
180 if {$subcom != "takekey"} {
181 if {[validchan $chan] == 0} {
182 putbot $bot "gop_resp I don't monitor $chan."
183 return 0
184 }
185 if {[onchan $botnick $chan] == 0} {
186 putbot $bot "gop_resp I am not on $chan."
187 return 0
188 }
189 }
190
191 switch -exact $subcom {
192 "op" {
193 if {[onchan $nick $chan] == 0} {
194 putbot $bot "gop_resp You are not on $chan for me."
195 return 1
196 }
197 set bothand [finduser $nick![getchanhost $nick $chan]]
198 if {$bothand == "*"} {
199 putlog "GetOps: $bot requested ops on $chan. Ident not recognized: $nick![getchanhost $nick $chan]."
200 putbot $bot "gop_resp I don't recognize you on IRC (your ident: $nick![getchanhost $nick $chan])"
201 return 1
202 }
203 if {[string tolower $bothand] == [string tolower $nick]} {
204 putlog "GetOps: $bot requested ops on $chan."
205 } {
206 putlog "GetOps: $bot requested ops as $nick on $chan."
207 }
208 if {[iso $nick $chan] && [matchattr $bothand b]} {
209 if {[botisop $chan]} {
210 if {[isop $nick $chan] == 0} {
211 putlog "GetOps: $nick asked for op on $chan."
212 putbot $bot "gop_resp Opped $nick on $chan."
213 pushmode $chan +o $nick
214 }
215 } {
216 putbot $bot "gop_resp I am not +o on $chan."
217 }
218 } {
219 putbot $bot "gop_resp You aren't +o in my userlist for $chan, sorry."
220 }
221 return 1
222 }
223 "unban" {
224 if {$go_bot_unban} {
225 putlog "GetOps: $bot requested that I unban him on $chan."
226 foreach ban [chanbans $chan] {
227 if {[string compare $nick $ban]} {
228 set bug_1 [lindex $ban 0]
229 pushmode $chan -b $bug_1
230 }
231 }
232 return 1
233 } {
234 putlog "GetOps: Refused request to unban $bot ($nick) on $chan."
235 putbot $bot "gop_resp Sorry, not accepting unban requests."
236 }
237 }
238 "invite" {
239 putlog "GetOps: $bot asked for an invite to $chan."
240 putserv "invite $nick $idchan"
241 return 1
242 }
243 "limit" {
244 putlog "GetOps: $bot asked for a limit raise on $chan."
245 pushmode $chan +l [expr [llength [chanlist $chan]] + 1]
246 return 1
247 }
248 "key" {
249 putlog "GetOps: $bot requested the key on $chan."
250 if {[string match *k* [lindex [getchanmode $chan] 0]]} {
251 putbot $bot "gop takekey $chan [lindex [getchanmode $chan] 1]"
252 } {
253 putbot $bot "gop_resp There isn't a key on $chan!"
254 }
255 return 1
256 }
257 "takekey" {
258 putlog "GetOps: $bot gave me the key to $chan! ($nick)"
259 foreach channel [string tolower [channels]] {
260 if {$chan == $channel} {
261 putserv "JOIN $idchan $nick"
262 return 1
263 }
264 }
265 }
266 default {
267 putlog "GetOps: ALERT! $bot sent fake 'gop' message! ($subcom)"
268 }
269 }
270 }
271
272 proc gop_resp {bot com msg} {
273 putlog "GetOps: MSG from $bot: $msg"
274 return 1
275 }
276
277 proc lbots {} {
278 set unf ""
279 foreach users [userlist b] {
280 foreach bs [bots] {
281 if {$users == $bs} {
282 lappend unf $users
283 }
284 }
285 }
286 return $unf
287 }
288
289 # Returns list of bots in the botnet and +o in my userfile on that channel
290 proc lobots { channel } {
291 set unf ""
292 foreach users [userlist b] {
293 if {[matchattr $users o|o $channel] == 0} { continue }
294 foreach bs [bots] {
295 if {$users == $bs} { lappend unf $users }
296 }
297 }
298 return $unf
299 }
300
301 proc iso {nick chan1} {
302 return [matchattr [nick2hand $nick $chan1] o|o $chan1]
303 }
304
305 proc do_channels {} {
306 global go_chanset
307 foreach a [string tolower [channels]] {
308 if {[info exist go_chanset($a)] == 0} {
309 channel set $a need-op "gain_entrance op $a"
310 channel set $a need-key "gain_entrance key $a"
311 channel set $a need-invite "gain_entrance invite $a"
312 channel set $a need-unban "gain_entrance unban $a"
313 channel set $a need-limit "gain_entrance limit $a"
314 set go_chanset($a) 1
315 }
316 }
317 if {[string match "*do_channels*" [timers]] == 0} { timer 5 do_channels }
318 }
319
320 if {[string match "*do_channels*" [utimers]] == 0} {
321 # Set things up one second after starting (dynamic things already loaded)
322 utimer 1 do_channels
323 }
324
325 bind bot - gop botnet_request
326 bind bot - gop_resp gop_resp
327
328 # Ask for ops when joining a channel
329 bind join - * gop_join
330
331 # Get the key after getting opped
332 bind mode - "* +o" get_key
333
334 proc get_key { nick uhost hand chan mode whom } {
335 global botnick
336 if {$botnick == $whom} {
337 puthelp "MODE [chandname2name $chan]"
338 }
339 return 0
340 }
341
342 proc requestop { chan } {
343 global botnick
344 set chan [string tolower $chan]
345 foreach thisbot [lobots $chan] {
346 # Send request to all, because the bot does not have the channel info yet
347 putbot $thisbot "gop op $chan $botnick"
348 lappend askedbot $thisbot
349 }
350 if {[info exist askedbot]} {
351 regsub -all " " $askedbot ", " askedbot
352 putlog "GetOps: Requested Ops from $askedbot on $chan."
353 } {
354 putlog "GetOps: No bots to ask for ops on $chan."
355 }
356 return 0
357 }
358
359 proc gop_join { nick uhost hand chan } {
360 global botnick
361 # Check if it was me joining
362 if {$nick != $botnick} { return 0 }
363 # Adjust channel settings, if needed (e.g when a dynamic channel was added)
364 do_channels
365 set chan [string tolower $chan]
366 # Wait 3 sec, because IRC-lag > Botnet-Lag
367 utimer 3 "requestop $chan"
368 return 0
369 }
370
371 set getops_loaded 1
372
373 putlog "GetOps v2.2e by Fabian, brainsick, Progfou, Cron@irc.pl, dtM, The_O, DarkDruid & Ernst loaded."

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23