/[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.12 - (hide annotations) (download) (as text)
Sun Jul 15 05:26:41 2001 UTC (18 years, 4 months ago) by guppy
Branch: MAIN
CVS Tags: eggdrop1_6_6
Changes since 1.11: +2 -2 lines
File MIME type: application/x-tcl
here is a fix for getops and I moved ITE's patches to 1.6.6

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23