/[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.18 - (show annotations) (download) (as text)
Wed Mar 26 00:19:30 2003 UTC (16 years, 8 months ago) by wcc
Branch: MAIN
CVS Tags: r1, eggdrop_1_6_15, blah, test, HEAD
Changes since 1.17: +7 -3 lines
File MIME type: application/x-tcl
* Fixed getops timer handling. Patch by PPSlim.

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23