/[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.15 - (show annotations) (download) (as text)
Mon Nov 5 04:08:28 2001 UTC (18 years, 8 months ago) by guppy
Branch: MAIN
Changes since 1.14: +2 -2 lines
File MIME type: application/x-tcl
Wcc is much better at spelling then us

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23