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

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

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


Revision 1.10 - (hide annotations) (download) (as text)
Fri Jun 1 22:07:32 2001 UTC (18 years, 6 months ago) by poptix
Branch: MAIN
Changes since 1.9: +17 -12 lines
File MIME type: application/x-tcl
*** empty log message ***

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23