/[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.9 - (show annotations) (download) (as text)
Wed May 23 07:00:41 2001 UTC (18 years, 6 months ago) by poptix
Branch: MAIN
Changes since 1.8: +2 -2 lines
File MIME type: application/x-tcl

Added my email address, actually testing cvs, guppy says I have write acces
CVS says otherwise...

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23