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

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

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


Revision 1.1 - (hide annotations) (download) (as text)
Wed Nov 8 19:52:38 2000 UTC (19 years, 1 month ago) by guppy
Branch: MAIN
File MIME type: application/x-tcl
guppy: applied sentinelupgrade.diff, did I remember to add the files?

1 guppy 1.1 # sentinel.tcl v2.00 (15 July 2000)
2     # copyright (c) 1998-2000 by slennox <slennox@egghelp.org>
3     # slennox's eggdrop page - http://www.egghelp.org/
4     #
5     # Flood protection system for eggdrop, with integrated BitchX CTCP
6     # simulation. This script is designed to provide strong protection for your
7     # bot and channels against large floodnets and proxy floods.
8     #
9     # v2.00 - New standalone release. Contains refinements and features from
10     # the netbots.tcl version of sentinel.tcl.
11     #
12     # sentinel.tcl is centered around its channel lock mechanism. It sets the
13     # channel +mi (moderated and invite-only) whenever a substantial flood on
14     # the channel is detected. This ensures channel stability when flooded,
15     # allowing the bots to deal with the flood as smoothly as possible.
16     # sentinel.tcl detects the following types of floods:
17     #
18     # * Channel CTCP floods. This is the most common type of flood, and will
19     # often make users quit from the channel with 'Excess Flood'. A quick
20     # channel lock can prevent this.
21     # * Channel join-part floods. A common type of channel flood in which
22     # many floodbots cycle the channel.
23     # * Channel nick floods. Nick floods are unique in that they can occur even
24     # after a channel is locked. sentinel has special mechanisms to deal with
25     # this as effectively as possible.
26     # * Channel avalanche floods. This type of flood is quite uncommon these
27     # days.
28     # * Channel text floods. Not small text floods - but when hundreds of
29     # messages are sent to the channel within a short period. Detected to
30     # prevent the bot from consuming high CPU and getting killed from the
31     # shell.
32     #
33     # sentinel also has additional protection features for the bot and channel:
34     #
35     # * Bogus username detection. Users with annoying bogus characters in their
36     # ident are banned. A channel lock is applied if multiple join in a short
37     # period.
38     # * Full ban list detection. During a serious flood, the ban list may
39     # become full. If this happens, the bots may start kick flooding since
40     # they cannot ban. If the ban list is full, the channel will be set +i.
41     # * Bot CTCP flood protection. Protects the bot if it is CTCP flooded.
42     # * Bot MSG flood protection. Protects the bot if it's flooded with MSGs or
43     # MSG commands.
44     # * Automatic bans and ignores. During a flood, sentinel will compile a
45     # list of the flooders, and kick-ban them after the channel has been
46     # locked.
47     # * BitchX simulation. This has been built-in mainly because you cannot use
48     # a third-party BitchX simulator with sentinel (only one script at a time
49     # can have control of CTCPs). sentinel provides accurate simulation of
50     # BitchX 75p1+ and 75p3+ CTCP replies and AWAY mode.
51     # * Public commands (lc and uc) and DCC commands (.lock and .unlock) for
52     # locking/unlocking channels.
53     # * DCC command .sentinel displays current settings.
54     #
55     # Important Notes:
56     # - Make sure no bots are enforcing channel mode -i and/or -m.
57     # - Bans are added to the bot's internal ban list, and expire after 24
58     # hours by default. If you have +dynamicbans set, the bans may be removed
59     # from the channel much sooner than this, but the ban will remain in the
60     # bot's internal ban list until it expires.
61     # - For greater protection against large channel floods, I recommend you
62     # also a channel limiter script, such as chanlimit.tcl.
63     # - Where security is paramount, have one or two bots that aren't running
64     # sentinel.tcl. Since sentinel.tcl is a complex script with many
65     # automated and convenience features, there is a small potential for
66     # vulnerabilities.
67    
68     # The following flood settings are in number:seconds format, 0:0 to
69     # disable.
70    
71     # Bot CTCP flood.
72     set sl_bcflood 5:30
73     # Bot MSG flood.
74     set sl_bmflood 6:20
75     # Channel CTCP flood.
76     set sl_ccflood 5:20
77     # Channel avalanche flood.
78     set sl_avflood 6:20
79     # Channel text flood.
80     set sl_txflood 80:30
81     # Channel bogus username join flood.
82     set sl_boflood 4:20
83     # Channel join-part flood.
84     set sl_jflood 6:20
85     # Channel nick flood.
86     set sl_nkflood 6:20
87    
88     # Flood setting notes:
89     # - Don't fiddle too much with the seconds field in the flood settings, as
90     # it can reduce the effectiveness of the script. The seconds field should
91     # set in the 20-60 seconds range.
92     # - Avalanche flood detection may be CPU intensive on a busy channel, so
93     # you may wish to disable it (perhaps leaving it enabled on one bot).
94     # Disabling text flood protection can further reduce CPU usage.
95     # - On bots with avalanche flood detection enabled, it's strongly
96     # recommended that you also enable text flood detection.
97     # - If you enable nick flood detection, it's strongly recommended that it
98     # be enabled on all bots that have sentinel.tcl loaded. This is required
99     # for effective nick flood handling.
100    
101     # Length of time in minutes to ban channel flooders. This makes the bot
102     # perform kicks and bans on flooders after the channel lock. For the most
103     # effective protection, you should disable this on at least one bot.
104     set sl_ban 1440
105     # Valid settings: 0 to disable, otherwise 1 or higher.
106    
107     # Length of time in minutes of on-join bans for bogus usernames. For the
108     # most effective protection, you should disable this on at least one bot.
109     set sl_boban 1440
110     # Valid settings: 0 to disable, otherwise 1 or higher.
111    
112     # Set global bans on channel flooders and bogus usernames?
113     set sl_globalban 0
114     # Valid settings: 1 for global bans, 0 for channel-specific bans.
115    
116     # Maximum number of bans allowed in the bot's ban list before sentinel will
117     # stop adding new bans. This prevents the bot from adding hundreds of bans
118     # on really large floods. Note that this has nothing to do with the channel
119     # ban list.
120     set sl_banmax 100
121     # Valid settings: 1 or higher.
122    
123     # Length of time in minutes to ignore bot flooders. On bots with sl_ban
124     # active, channel flooders are also added to the ignore list.
125     set sl_igtime 240
126     # Valid settings: 1 or higher.
127    
128     # Length of time in seconds to set channel +i if flooded. If set to 0, +i
129     # will not be removed automatically.
130     set sl_ilocktime 120
131     # Valid settings: 0 to prevent +i being removed automatically, otherwise 30
132     # or higher.
133    
134     # Length of time in seconds to set channel +m if flooded. If set to 0, +m
135     # will not be removed automatically.
136     set sl_mlocktime 60
137     # Valid settings: 0 to prevent +m being removed automatically, otherwise 30
138     # or higher.
139    
140     # On small floods (two flooders or less), remove the +mi shortly after bans
141     # have been set, instead of waiting for the locktimes to expire? This
142     # prevents unnecessary extended locks on small floods. This setting is only
143     # used by bots with sl_ban enabled.
144     set sl_shortlock 0
145     # Valid settings: 0 to disable, 1 to enable.
146    
147     # Number of bans to allow in the channel ban list before setting the
148     # channel +i. If enabled, this should preferably be set to just below the
149     # maximum number of bans allowed.
150     set sl_bfmaxbans 19
151     # Valid settings: 0 to disable +i on full ban list, otherwise 1 or higher.
152    
153     # List of users to send a note to when channel is flooded, bot is flooded,
154     # or ban list becomes full.
155     set sl_note "YourNick"
156     # Valid settings: one user like "Tom", a list of users like
157     # "Tom Dick Harry", or "" to specify that no notes are sent.
158    
159     # Notice to send to channel when locked due to flood.
160     set sl_cfnotice "Channel locked temporarily due to flood, sorry for any inconvenience this may cause :-)"
161     # Valid settings: a text string, or set it to "" to disable.
162    
163     # Notice to send to channel when locked due to full ban list.
164     set sl_bfnotice "Channel locked temporarily due to full ban list, sorry for any inconvenience this may cause :-)"
165     # Valid settings: can be set to "" to disable.
166    
167     # Enable 'lc' and 'uc' public commands for locking/unlocking channel?
168     set sl_lockcmds 2
169     # Valid settings: 0 to disable, 1 to enable, 2 to require user to be opped
170     # on the channel to use the command.
171    
172     # Users with these flags are allowed to use lc/uc public commands, and
173     # .lock/.unlock DCC commands.
174     set sl_lockflags "o"
175     # Valid settings: one flag like "n", or a list of flags like "fo" (means
176     # 'f OR o').
177    
178     # Enable BitchX CTCP and AWAY simulation?
179     set sl_bxsimul 0
180     # Valid settings: 1 to enable, 0 to disable.
181    
182    
183     # Don't edit below unless you know what you're doing.
184    
185     if {$numversion < 1032400} {
186     if {[info commands onchan] != ""} {
187     proc botonchan {chan} {
188     global botnick
189     if {![validchan $chan]} {
190     error "illegal channel: $chan"
191     } elseif {![onchan $botnick $chan]} {
192     return 0
193     }
194     return 1
195     }
196     }
197     proc putquick {text} {
198     putserv $text
199     }
200     }
201    
202     proc sl_ctcp {nick uhost hand dest key arg} {
203     global botnet-nick botnick realname sl_ban sl_bflooded sl_bcflood sl_bcqueue sl_bxjointime sl_bxmachine sl_bxonestack sl_bxsimul sl_bxsystem sl_bxversion sl_bxwhoami sl_ccbanhost sl_ccbannick sl_ccflood sl_ccqueue sl_flooded sl_locked sl_note
204     set chan [string tolower $dest]
205     if {(([lsearch -exact $sl_ccflood 0] == -1) && ([validchan $chan]) && (![isop $nick $chan]))} {
206     if {$nick == $botnick} {return 0}
207     if {(($sl_ban) && (!$sl_locked($chan)) && (![matchattr $hand f|f $chan]))} {
208     lappend sl_ccbannick($chan) $nick ; lappend sl_ccbanhost($chan) *!*[string tolower [string range $uhost [string first @ $uhost] end]]
209     utimer [lindex $sl_ccflood 1] [split "sl_ccbanqueue $chan"]
210     }
211     if {$sl_flooded($chan)} {return 1}
212     incr sl_ccqueue($chan)
213     utimer [lindex $sl_ccflood 1] [split "sl_ccqueuereset $chan"]
214     if {$sl_ccqueue($chan) >= [lindex $sl_ccflood 0]} {
215     sl_lock $chan "CTCP flood" ${botnet-nick} ; return 1
216     }
217     if {$sl_bflooded} {return 1}
218     } elseif {(([lindex $sl_bcflood 0]) && ($dest == $botnick))} {
219     if {$sl_bflooded} {
220     sl_ignore $uhost $hand "CTCP flooder" ; return 1
221     }
222     incr sl_bcqueue
223     utimer [lindex $sl_bcflood 1] "incr sl_bcqueue -1"
224     if {$sl_bcqueue >= [lindex $sl_bcflood 0]} {
225     putlog "sentinel: CTCP flood detected on me! Stopped answering CTCPs temporarily."
226     set sl_bflooded 1
227     utimer [lindex $sl_bcflood 1] "set sl_bflooded 0"
228     if {[info commands sendnote] != ""} {
229     foreach recipient $sl_note {
230     if {[validuser $recipient]} {
231     sendnote SENTINEL $recipient "Bot was CTCP flooded."
232     }
233     }
234     }
235     return 1
236     }
237     }
238    
239     if {!$sl_bxsimul} {return 0}
240     if {$sl_bxonestack} {return 1}
241     set sl_bxonestack 1 ; utimer 2 "set sl_bxonestack 0"
242     switch -exact -- $key {
243     "CLIENTINFO" {
244     set bxcmd [string toupper $arg]
245     switch -exact -- $bxcmd {
246     "" {putserv "NOTICE $nick :\001CLIENTINFO SED UTC ACTION DCC CDCC BDCC XDCC VERSION CLIENTINFO USERINFO ERRMSG FINGER TIME PING ECHO INVITE WHOAMI OP OPS UNBAN IDENT XLINK UPTIME :Use CLIENTINFO <COMMAND> to get more specific information\001"}
247     "SED" {putserv "NOTICE $nick :\001CLIENTINFO SED contains simple_encrypted_data\001"}
248     "UTC" {putserv "NOTICE $nick :\001CLIENTINFO UTC substitutes the local timezone\001"}
249     "ACTION" {putserv "NOTICE $nick :\001CLIENTINFO ACTION contains action descriptions for atmosphere\001"}
250     "DCC" {putserv "NOTICE $nick :\001CLIENTINFO DCC requests a direct_client_connection\001"}
251     "CDCC" {putserv "NOTICE $nick :\001CLIENTINFO CDCC checks cdcc info for you\001"}
252     "BDCC" {putserv "NOTICE $nick :\001CLIENTINFO BDCC checks cdcc info for you\001"}
253     "XDCC" {putserv "NOTICE $nick :\001CLIENTINFO XDCC checks cdcc info for you\001"}
254     "VERSION" {putserv "NOTICE $nick :\001CLIENTINFO VERSION shows client type, version and environment\001"}
255     "CLIENTINFO" {putserv "NOTICE $nick :\001CLIENTINFO CLIENTINFO gives information about available CTCP commands\001"}
256     "USERINFO" {putserv "NOTICE $nick :\001CLIENTINFO USERINFO returns user settable information\001"}
257     "ERRMSG" {putserv "NOTICE $nick :\001CLIENTINFO ERRMSG returns error messages\001"}
258     "FINGER" {putserv "NOTICE $nick :\001CLIENTINFO FINGER shows real name, login name and idle time of user\001"}
259     "TIME" {putserv "NOTICE $nick :\001CLIENTINFO TIME tells you the time on the user's host\001"}
260     "PING" {putserv "NOTICE $nick :\001CLIENTINFO PING returns the arguments it receives\001"}
261     "ECHO" {putserv "NOTICE $nick :\001CLIENTINFO ECHO returns the arguments it receives\001"}
262     "INVITE" {putserv "NOTICE $nick :\001CLIENTINFO INVITE invite to channel specified\001"}
263     "WHOAMI" {putserv "NOTICE $nick :\001CLIENTINFO WHOAMI user list information\001"}
264     "OP" {putserv "NOTICE $nick :\001CLIENTINFO OP ops the person if on userlist\001"}
265     "OPS" {putserv "NOTICE $nick :\001CLIENTINFO OPS ops the person if on userlist\001"}
266     "UNBAN" {putserv "NOTICE $nick :\001CLIENTINFO UNBAN unbans the person from channel\001"}
267     "IDENT" {putserv "NOTICE $nick :\001CLIENTINFO IDENT change userhost of userlist\001"}
268     "XLINK" {putserv "NOTICE $nick :\001CLIENTINFO XLINK x-filez rule\001"}
269     "UPTIME" {putserv "NOTICE $nick :\001CLIENTINFO UPTIME my uptime\001"}
270     "default" {putserv "NOTICE $nick :\001ERRMSG CLIENTINFO: $arg is not a valid function\001"}
271     }
272     return 1
273     }
274     "VERSION" {
275     putserv "NOTICE $nick :\001VERSION \002BitchX-$sl_bxversion\002 by panasync \002-\002 $sl_bxsystem :\002 Keep it to yourself!\002\001"
276     return 1
277     }
278     "USERINFO" {
279     putserv "NOTICE $nick :\001USERINFO \001"
280     return 1
281     }
282     "FINGER" {
283     putserv "NOTICE $nick :\001FINGER $realname ($sl_bxwhoami@$sl_bxmachine) Idle [expr [unixtime] - $sl_bxjointime] seconds\001"
284     return 1
285     }
286     "PING" {
287     putserv "NOTICE $nick :\001PING $arg\001"
288     return 1
289     }
290     "ECHO" {
291     if {[validchan $chan]} {return 1}
292     putserv "NOTICE $nick :\001ECHO [string range $arg 0 59]\001"
293     return 1
294     }
295     "ERRMSG" {
296     if {[validchan $chan]} {return 1}
297     putserv "NOTICE $nick :\001ERRMSG [string range $arg 0 59]\001"
298     return 1
299     }
300     "INVITE" {
301     if {(($arg == "") || ([validchan $chan]))} {return 1}
302     set chanarg [lindex [split $arg] 0]
303     if {((($sl_bxversion == "75p1+") && ([string trim [string index $chanarg 0] "#+&"] == "")) || (($sl_bxversion == "75p3+") && ([string trim [string index $chanarg 0] "#+&!"] == "")))} {
304     if {[validchan $chanarg]} {
305     putserv "NOTICE $nick :\002BitchX\002: Access Denied"
306     } else {
307     putserv "NOTICE $nick :\002BitchX\002: I'm not on that channel"
308     }
309     }
310     return 1
311     }
312     "WHOAMI" {
313     if {[validchan $chan]} {return 1}
314     putserv "NOTICE $nick :\002BitchX\002: Access Denied"
315     return 1
316     }
317     "OP" -
318     "OPS" {
319     if {(($arg == "") || ([validchan $chan]))} {return 1}
320     putserv "NOTICE $nick :\002BitchX\002: I'm not on [lindex [split $arg] 0], or I'm not opped"
321     return 1
322     }
323     "UNBAN" {
324     if {(($arg == "") || ([validchan $chan]))} {return 1}
325     if {[validchan [lindex [split $arg] 0]]} {
326     putserv "NOTICE $nick :\002BitchX\002: Access Denied"
327     } else {
328     putserv "NOTICE $nick :\002BitchX\002: I'm not on that channel"
329     }
330     return 1
331     }
332     }
333     return 0
334     }
335    
336     proc sl_bmflood {nick uhost hand text} {
337     global sl_bmflood sl_bflooded sl_bmqueue sl_note
338     if {(([matchattr $hand b]) && ([string tolower [lindex [split $text] 0]] == "go"))} {return 0}
339     if {$sl_bflooded} {
340     sl_ignore $uhost $hand "MSG flooder" ; return 0
341     }
342     incr sl_bmqueue
343     utimer [lindex $sl_bmflood 1] "incr sl_bmqueue -1"
344     if {$sl_bmqueue >= [lindex $sl_bmflood 0]} {
345     putlog "sentinel: MSG flood detected on me! Stopped answering MSGs temporarily."
346     set sl_bflooded 1
347     utimer [lindex $sl_bmflood 1] "set sl_bflooded 0"
348     if {[info commands sendnote] != ""} {
349     foreach recipient $sl_note {
350     if {[validuser $recipient]} {
351     sendnote SENTINEL $recipient "Bot was MSG flooded."
352     }
353     }
354     }
355     }
356     return 0
357     }
358    
359     proc sl_avflood {from keyword arg} {
360     global botnet-nick botnick sl_ban sl_avbanhost sl_avbannick sl_avflood sl_avqueue sl_flooded sl_locked sl_txflood sl_txqueue
361     set arg [split $arg]
362     set chan [string tolower [lindex $arg 0]]
363     if {![validchan $chan]} {return 0}
364     set nick [lindex [split $from !] 0]
365     if {(($nick == $botnick) || ($nick == "") || ([string match *.* $nick]))} {return 0}
366     if {((![onchan $nick $chan]) || ([isop $nick $chan]))} {return 0}
367     if {((!$sl_flooded($chan)) && ([lsearch -exact $sl_txflood 0] == -1))} {
368     incr sl_txqueue($chan)
369     if {$sl_txqueue($chan) >= [lindex $sl_txflood 0]} {
370     sl_lock $chan "TEXT flood" ${botnet-nick}
371     }
372     }
373     set text [join [lrange $arg 1 end]]
374     if {(([sl_checkaval $text]) && ([lsearch -exact $sl_avflood 0] == -1))} {
375     set uhost [string trimleft [getchanhost $nick $chan] "~+-^="]
376     set hand [nick2hand $nick $chan]
377     if {(($sl_ban) && (!$sl_locked($chan)) && ($nick != $botnick) && (![matchattr $hand f|f $chan]))} {
378     lappend sl_avbannick($chan) $nick ; lappend sl_avbanhost($chan) *!*[string tolower [string range $uhost [string first @ $uhost] end]]
379     utimer [lindex $sl_avflood 1] [split "sl_avbanqueue $chan"]
380     }
381     if {$sl_flooded($chan)} {return 0}
382     incr sl_avqueue($chan)
383     utimer [lindex $sl_avflood 1] [split "sl_avqueuereset $chan"]
384     if {$sl_avqueue($chan) >= [lindex $sl_avflood 0]} {
385     sl_lock $chan "AVALANCHE flood" ${botnet-nick}
386     }
387     }
388     return 0
389     }
390    
391     proc sl_checkaval {text} {
392     if {[expr [regsub -all -- "\007" $text "" temp] + [regsub -all -- "\001" $temp "" temp]] >= 3} {return 1}
393     return 0
394     }
395    
396     proc sl_nkflood {nick uhost hand chan newnick} {
397     global botnet-nick botnick sl_ban sl_banmax sl_flooded sl_globalban sl_locked sl_nickkick sl_nkbanhost sl_nkflood sl_nkflooding sl_nkqueue
398     set chan [string tolower $chan]
399     if {[isop $newnick $chan]} {return 0}
400     if {(($sl_ban) && (!$sl_locked($chan)) && ($nick != $botnick) && (![matchattr $hand f|f $chan]))} {
401     lappend sl_nkbanhost($chan) *!*[string tolower [string range $uhost [string first @ $uhost] end]]
402     utimer [lindex $sl_nkflood 1] [split "sl_nkbanqueue $chan"]
403     }
404     if {((!$sl_nickkick) && ($sl_flooded($chan)) && ($sl_locked($chan)))} {
405     putserv "KICK $chan $newnick :NICK flooder"
406     set sl_nickkick 1 ; set sl_nkflooding($chan) [unixtime]
407     if {$sl_ban} {
408     set bhost *!*[string tolower [string range $uhost [string first @ $uhost] end]]
409     if {$sl_globalban} {
410     if {(([llength [banlist]] < $sl_banmax) && (![isban $bhost]))} {
411     newban $bhost sentinel "NICK flooder" $sl_ban
412     }
413     } else {
414     if {(([llength [banlist $chan]] < $sl_banmax) && (![isban $bhost $chan]))} {
415     newchanban $chan $bhost sentinel "NICK flooder" $sl_ban
416     }
417     }
418     }
419     utimer [expr [rand 2] + 3] "set sl_nickkick 0"
420     return 0
421     }
422     if {$sl_flooded($chan)} {return 0}
423     incr sl_nkqueue($chan)
424     utimer [lindex $sl_nkflood 1] [split "sl_nkqueuereset $chan"]
425     if {$sl_nkqueue($chan) >= [lindex $sl_nkflood 0]} {
426     sl_lock $chan "NICK flood" ${botnet-nick}
427     }
428     return 0
429     }
430    
431     proc sl_jflood {nick uhost hand chan} {
432     global botnet-nick botnick sl_ban sl_banmax sl_boban sl_bobanhost sl_bobannick sl_boflood sl_boqueue sl_flooded sl_globalban sl_jbanhost sl_jbannick sl_jflood sl_jqueue sl_locked sl_pqueue
433     if {$nick == $botnick} {
434     sl_setarray $chan
435     } else {
436     set ihost *!*[string tolower [string range $uhost [string first @ $uhost] end]]
437     if {[isignore $ihost]} {
438     killignore $ihost
439     }
440     set chan [string tolower $chan]
441     if {(([lsearch -exact $sl_boflood 0] == -1) && ([sl_checkbogus [lindex [split $uhost @] 0]]))} {
442     if {((!$sl_locked($chan)) && (![matchattr $hand f|f $chan]))} {
443     set bhost *!*[string tolower [string range $uhost [string first @ $uhost] end]]
444     if {(($sl_boban) && ([botisop $chan]) && (!$sl_flooded($chan)))} {
445     putserv "KICK $chan $nick :BOGUS username"
446     if {$sl_globalban} {
447     if {(([llength [banlist]] < $sl_banmax) && (![isban $bhost]))} {
448     newban $bhost sentinel "BOGUS username" $sl_boban
449     }
450     } else {
451     if {(([llength [banlist $chan]] < $sl_banmax) && (![isban $bhost $chan]))} {
452     newchanban $chan $bhost sentinel "BOGUS username" $sl_boban
453     }
454     }
455     }
456     if {$sl_ban} {
457     lappend sl_bobannick($chan) $nick ; lappend sl_bobanhost($chan) $bhost
458     utimer [lindex $sl_boflood 1] [split "sl_bobanqueue $chan"]
459     }
460     }
461     if {!$sl_flooded($chan)} {
462     incr sl_boqueue($chan)
463     utimer [lindex $sl_boflood 1] [split "sl_boqueuereset $chan"]
464     if {$sl_boqueue($chan) >= [lindex $sl_boflood 0]} {
465     sl_lock $chan "BOGUS joins" ${botnet-nick}
466     }
467     }
468     }
469     if {[lsearch -exact $sl_jflood 0] == -1} {
470     if {(($sl_ban) && (!$sl_locked($chan)) && (![matchattr $hand f|f $chan]))} {
471     lappend sl_jbannick($chan) $nick ; lappend sl_jbanhost($chan) *!*[string tolower [string range $uhost [string first @ $uhost] end]]
472     utimer [lindex $sl_jflood 1] [split "sl_jbanqueue $chan"]
473     }
474     if {$sl_flooded($chan)} {return 0}
475     incr sl_jqueue($chan)
476     utimer [lindex $sl_jflood 1] [split "sl_jqueuereset $chan"]
477     if {(($sl_jqueue($chan) >= [lindex $sl_jflood 0]) && ($sl_pqueue($chan) >= [lindex $sl_jflood 0]))} {
478     sl_lock $chan "JOIN-PART flood" ${botnet-nick}
479     }
480     }
481     }
482     return 0
483     }
484    
485     proc sl_checkbogus {ident} {
486     if {[regsub -all -- "\[^\041-\176\]" $ident "" temp] >= 1} {return 1}
487     return 0
488     }
489    
490     proc sl_pflood {nick uhost hand chan {msg ""}} {
491     global botnick sl_ban sl_flooded sl_jflood sl_locked sl_pbanhost sl_pbannick sl_pqueue
492     if {[lsearch -exact $sl_jflood 0] != -1} {return 0}
493     if {$nick == $botnick} {return 0}
494     set chan [string tolower $chan]
495     if {(($sl_ban) && (!$sl_locked($chan)) && (![matchattr $hand f|f $chan]))} {
496     lappend sl_pbannick($chan) $nick ; lappend sl_pbanhost($chan) *!*[string tolower [string range $uhost [string first @ $uhost] end]]
497     utimer [lindex $sl_jflood 1] [split "sl_pbanqueue $chan"]
498     }
499     if {$sl_flooded($chan)} {return 0}
500     incr sl_pqueue($chan)
501     utimer [lindex $sl_jflood 1] [split "sl_pqueuereset $chan"]
502     return 0
503     }
504    
505     proc sl_pfloodk {nick uhost hand chan kicked reason} {
506     global botnick sl_flooded sl_jflood sl_pqueue
507     if {[lsearch -exact $sl_jflood 0] != -1} {return 0}
508     if {$kicked == $botnick} {return 0}
509     set chan [string tolower $chan]
510     if {$sl_flooded($chan)} {return 0}
511     incr sl_pqueue($chan)
512     utimer [lindex $sl_jflood 1] [split "sl_pqueuereset $chan"]
513     return 0
514     }
515    
516     proc sl_lock {chan flood detected} {
517     global botnet-nick sl_bflooded sl_cfnotice sl_flooded sl_ilocktime sl_mlocktime sl_note
518     if {$detected == ${botnet-nick}} {
519     set sl_flooded($chan) 1 ; set sl_bflooded 1
520     if {[botisop $chan]} {
521     putquick "MODE $chan +mi"
522     sl_killutimer "sl_unlock $chan *"
523     sl_killutimer "set sl_bflooded 0"
524     if {$sl_mlocktime} {
525     utimer $sl_mlocktime [split "sl_unlock $chan m"]
526     }
527     if {$sl_ilocktime} {
528     utimer $sl_ilocktime [split "sl_unlock $chan i"]
529     }
530     utimer 120 "set sl_bflooded 0"
531     putlog "sentinel: $flood detected on $chan! Channel locked temporarily."
532     if {$sl_cfnotice != ""} {
533     puthelp "NOTICE $chan :$sl_cfnotice"
534     }
535     } else {
536     putlog "sentinel: $flood detected on $chan! Cannot lock channel because I'm not opped."
537     utimer 120 "set sl_bflooded 0"
538     }
539     } else {
540     putlog "sentinel: $flood detected by $detected on $chan!"
541     }
542     if {[info commands sendnote] != ""} {
543     foreach recipient $sl_note {
544     if {[validuser $recipient]} {
545     if {$detected == ${botnet-nick}} {
546     sendnote SENTINEL $recipient "$flood detected on $chan."
547     } else {
548     sendnote SENTINEL $recipient "$flood detected by $detected on $chan."
549     }
550     }
551     }
552     }
553     return 0
554     }
555    
556     proc sl_unlock {chan umode} {
557     global sl_bflooded sl_bfmaxbans sl_flooded sl_ilocktime sl_mlocktime sl_nkflooding
558     if {[expr [unixtime] - $sl_nkflooding($chan)] < 12} {
559     putlog "sentinel: nick flooding still in progress on $chan - not removing +mi yet.."
560     set sl_flooded($chan) 1 ; set sl_bflooded 1
561     sl_killutimer "sl_unlock $chan *"
562     sl_killutimer "set sl_bflooded 0"
563     utimer $sl_mlocktime [split "sl_unlock $chan m"] ; utimer $sl_ilocktime [split "sl_unlock $chan i"]
564     utimer 120 "set sl_bflooded 0"
565     } else {
566     set sl_flooded($chan) 0
567     if {![botisop $chan]} {return 0}
568     if {$umode == "mi"} {
569     putlog "sentinel: flood was small, performing early unlock.."
570     }
571     if {(([string match *i* $umode]) && ([string match *i* [lindex [split [getchanmode $chan]] 0]]))} {
572     if {(($sl_bfmaxbans) && ([llength [chanbans $chan]] >= $sl_bfmaxbans))} {
573     putlog "sentinel: not removing +i on $chan due to full ban list."
574     } else {
575     pushmode $chan -i
576     putlog "sentinel: removed +i on $chan"
577     }
578     }
579     if {(([string match *m* $umode]) && ([string match *m* [lindex [split [getchanmode $chan]] 0]]))} {
580     pushmode $chan -m
581     putlog "sentinel: removed +m on $chan"
582     }
583     }
584     return 0
585     }
586    
587     proc sl_mode {nick uhost hand chan mode victim} {
588     global botnick sl_ban sl_bfmaxbans sl_bfnotice sl_bfull sl_flooded sl_locked sl_note sl_unlocked
589     set chan [string tolower $chan]
590     if {(($mode == "+b") && ($sl_bfmaxbans) && (!$sl_bfull($chan)) && (![string match *i* [lindex [split [getchanmode $chan]] 0]]) && ([botisop $chan]) && ([llength [chanbans $chan]] >= $sl_bfmaxbans))} {
591     putserv "MODE $chan +i"
592     set sl_bfull($chan) 1
593     utimer 5 [split "set sl_bfull($chan) 0"]
594     putlog "sentinel: locked $chan due to full ban list!"
595     if {$sl_bfnotice != ""} {
596     puthelp "NOTICE $chan :$sl_bfnotice"
597     }
598     if {[info commands sendnote] != ""} {
599     foreach recipient $sl_note {
600     if {[validuser $recipient]} {
601     sendnote SENTINEL $recipient "Locked $chan due to full ban list."
602     }
603     }
604     }
605     } elseif {(($mode == "+i") && ($sl_flooded($chan)))} {
606     set sl_locked($chan) 1
607     if {$sl_ban} {
608     sl_killutimer "sl_*banqueue $chan"
609     utimer 7 [split "sl_dokicks $chan"] ; utimer 16 [split "sl_setbans $chan"]
610     }
611     } elseif {(($mode == "-i") || ($mode == "-m"))} {
612     set sl_locked($chan) 0
613     set sl_unlocked($chan) [unixtime]
614     if {$sl_flooded($chan)} {
615     set sl_flooded($chan) 0
616     if {$mode == "-i"} {
617     sl_killutimer "sl_unlock $chan i"
618     } else {
619     sl_killutimer "sl_unlock $chan m"
620     }
621     sl_killutimer "sl_unlock $chan mi"
622     if {$nick != $botnick} {
623     putlog "sentinel: $chan unlocked by $nick"
624     }
625     }
626     }
627     return 0
628     }
629    
630     proc sl_dokicks {chan} {
631     global sl_avbannick sl_bobannick sl_ccbannick sl_kflooders sl_jbannick sl_pbannick
632     if {((![botonchan $chan]) || (![botisop $chan]))} {return 0}
633     set sl_kflooders 0
634     sl_kick $chan $sl_ccbannick($chan) "CTCP flooder" ; set sl_ccbannick($chan) ""
635     sl_kick $chan $sl_avbannick($chan) "AVALANCHE flooder" ; set sl_avbannick($chan) ""
636     sl_kick $chan $sl_bobannick($chan) "BOGUS username" ; set sl_bobannick($chan) ""
637     set jklist $sl_jbannick($chan) ; set pklist $sl_pbannick($chan)
638     if {(($jklist != "") && ($pklist != ""))} {
639     set klist ""
640     foreach nick $jklist {
641     if {[lsearch -exact $pklist $nick] != -1} {
642     lappend klist $nick
643     }
644     }
645     sl_kick $chan $klist "JOIN-PART flooder"
646     }
647     set sl_jbannick($chan) "" ; set sl_pbannick($chan) ""
648     return 0
649     }
650    
651     proc sl_kick {chan klist reason} {
652     global sl_kflooders sl_kicks
653     if {$klist != ""} {
654     set kicklist ""
655     foreach nick $klist {
656     if {[lsearch -exact $kicklist $nick] == -1} {
657     lappend kicklist $nick
658     }
659     }
660     unset nick
661     incr sl_kflooders [llength $kicklist]
662     foreach nick $kicklist {
663     if {(([onchan $nick $chan]) && (![onchansplit $nick $chan]))} {
664     lappend ksend $nick
665     if {[llength $ksend] >= $sl_kicks} {
666     putserv "KICK $chan [join $ksend ,] :$reason"
667     unset ksend
668     }
669     }
670     }
671     if {[info exists ksend]} {
672     putserv "KICK $chan [join $ksend ,] :$reason"
673     }
674     }
675     return 0
676     }
677    
678     proc sl_setbans {chan} {
679     global sl_avbanhost sl_bflooders sl_bobanhost sl_ccbanhost sl_kflooders sl_jbanhost sl_nkbanhost sl_pbanhost sl_shortlock sl_unlocked
680     if {![botonchan $chan]} {return 0}
681     set sl_bflooders 0
682     sl_ban $chan $sl_ccbanhost($chan) "CTCP flooder" ; set sl_ccbanhost($chan) ""
683     sl_ban $chan $sl_avbanhost($chan) "AVALANCHE flooder" ; set sl_avbanhost($chan) ""
684     sl_ban $chan $sl_nkbanhost($chan) "NICK flooder" ; set sl_nkbanhost($chan) ""
685     sl_ban $chan $sl_bobanhost($chan) "BOGUS username" ; set sl_bobanhost($chan) ""
686     set jblist $sl_jbanhost($chan) ; set pblist $sl_pbanhost($chan)
687     if {(($jblist != "") && ($pblist != ""))} {
688     set blist ""
689     foreach bhost $jblist {
690     if {[lsearch -exact $pblist $bhost] != -1} {
691     lappend blist $bhost
692     }
693     }
694     sl_ban $chan $blist "JOIN-PART flooder"
695     }
696     set sl_jbanhost($chan) "" ; set sl_pbanhost($chan) ""
697     if {(($sl_shortlock) && ($sl_kflooders <= 2) && ($sl_bflooders <= 2) && ([expr [unixtime] - $sl_unlocked($chan)] > 120))} {
698     sl_killutimer "sl_unlock $chan *"
699     utimer 10 [split "sl_unlock $chan mi"]
700     }
701     return 0
702     }
703    
704     proc sl_ban {chan blist reason} {
705     global sl_ban sl_banmax sl_bflooders sl_globalban
706     if {$blist != ""} {
707     set banlist ""
708     foreach bhost $blist {
709     if {[lsearch -exact $banlist $bhost] == -1} {
710     lappend banlist $bhost
711     }
712     }
713     incr sl_bflooders [llength $banlist]
714     if {$sl_globalban} {
715     foreach bhost $banlist {
716     if {(([llength [banlist]] >= $sl_banmax) || ([isban $bhost]) || ([ispermban $bhost]))} {continue}
717     newban $bhost sentinel $reason $sl_ban
718     putlog "sentinel: banned $bhost ($reason)"
719     sl_ignore $bhost * $reason
720     }
721     } else {
722     foreach bhost $banlist {
723     if {(([llength [banlist $chan]] >= $sl_banmax) || ([isban $bhost $chan]) || ([ispermban $bhost $chan]))} {continue}
724     newchanban $chan $bhost sentinel $reason $sl_ban
725     putlog "sentinel: banned $bhost on $chan ($reason)"
726     sl_ignore $bhost * $reason
727     }
728     }
729     }
730     return 0
731     }
732    
733     proc sl_ignore {uhost hand flood} {
734     global sl_igtime
735     if {$hand != "*"} {
736     foreach chan [channels] {
737     if {[matchattr $hand f|f $chan]} {return 0}
738     }
739     }
740     set ihost *!*[string tolower [string range $uhost [string first @ $uhost] end]]
741     if {[isignore $ihost]} {return 0}
742     newignore $ihost sentinel $flood $sl_igtime
743     putlog "sentinel: added $ihost to ignore list ($flood)"
744     return 0
745     }
746    
747     proc sl_ccqueuereset {chan} {
748     global sl_ccqueue
749     incr sl_ccqueue($chan) -1
750     return 0
751     }
752    
753     proc sl_bcqueuereset {} {
754     global sl_bcqueue
755     incr sl_bcqueue -1
756     return 0
757     }
758    
759     proc sl_bmqueuereset {} {
760     global sl_bmqueue
761     incr sl_bmqueue -1
762     return 0
763     }
764    
765     proc sl_avqueuereset {chan} {
766     global sl_avqueue
767     incr sl_avqueue($chan) -1
768     return 0
769     }
770    
771     proc sl_txqueuereset {} {
772     global sl_txqueue sl_txflood
773     foreach chan [string tolower [channels]] {
774     if {[info exists sl_txqueue($chan)]} {
775     set sl_txqueue($chan) 0
776     }
777     }
778     utimer [lindex $sl_txflood 1] sl_txqueuereset
779     return 0
780     }
781    
782     proc sl_nkqueuereset {chan} {
783     global sl_nkqueue
784     incr sl_nkqueue($chan) -1
785     return 0
786     }
787    
788     proc sl_boqueuereset {chan} {
789     global sl_boqueue
790     incr sl_boqueue($chan) -1
791     return 0
792     }
793    
794     proc sl_jqueuereset {chan} {
795     global sl_jqueue
796     incr sl_jqueue($chan) -1
797     return 0
798     }
799    
800     proc sl_pqueuereset {chan} {
801     global sl_pqueue
802     incr sl_pqueue($chan) -1
803     return 0
804     }
805    
806     proc sl_ccbanqueue {chan} {
807     global sl_ccbanhost sl_ccbannick
808     set sl_ccbannick($chan) [lrange sl_ccbannick($chan) 1 end] ; set sl_ccbanhost($chan) [lrange sl_ccbanhost($chan) 1 end]
809     return 0
810     }
811    
812     proc sl_avbanqueue {chan} {
813     global sl_avbanhost sl_avbannick
814     set sl_avbannick($chan) [lrange sl_avbannick($chan) 1 end] ; set sl_avbanhost($chan) [lrange sl_avbanhost($chan) 1 end]
815     return 0
816     }
817    
818     proc sl_nkbanqueue {chan} {
819     global sl_nkbanhost
820     set sl_nkbanhost($chan) [lrange sl_nkbanhost($chan) 1 end]
821     return 0
822     }
823    
824     proc sl_bobanqueue {chan} {
825     global sl_bobanhost sl_bobannick
826     set sl_bobannick($chan) [lrange sl_bobannick($chan) 1 end] ; set sl_bobanhost($chan) [lrange sl_bobanhost($chan) 1 end]
827     return 0
828     }
829    
830     proc sl_jbanqueue {chan} {
831     global sl_jbanhost sl_jbannick
832     set sl_jbannick($chan) [lrange sl_jbannick($chan) 1 end] ; set sl_jbanhost($chan) [lrange sl_jbanhost($chan) 1 end]
833     return 0
834     }
835    
836     proc sl_pbanqueue {chan} {
837     global sl_pbanhost sl_pbannick
838     set sl_pbannick($chan) [lrange sl_pbannick($chan) 1 end] ; set sl_pbanhost($chan) [lrange sl_pbanhost($chan) 1 end]
839     return 0
840     }
841    
842     proc sl_flud {nick uhost hand type chan} {
843     global sl_flooded
844     set chan [string tolower $chan]
845     if {(([validchan $chan]) && ($sl_flooded($chan)))} {return 1}
846     return 0
847     }
848    
849     proc sl_lc {nick uhost hand chan arg} {
850     global sl_lockcmds
851     set chan [string tolower $chan]
852     if {![botisop $chan]} {return 0}
853     if {(($sl_lockcmds == 2) && (![isop $nick $chan]))} {return 0}
854     putquick "MODE $chan +mi"
855     putlog "sentinel: channel lock requested by $hand on $chan"
856     return 0
857     }
858    
859     proc sl_uc {nick uhost hand chan arg} {
860     global sl_lockcmds
861     set chan [string tolower $chan]
862     if {![botisop $chan]} {return 0}
863     if {(($sl_lockcmds == 2) && (![isop $nick $chan]))} {return 0}
864     putserv "MODE $chan -mi"
865     putlog "sentinel: channel unlock requested by $hand on $chan"
866     return 0
867     }
868    
869     proc sl_dcclc {hand idx arg} {
870     global sl_lockflags
871     putcmdlog "#$hand# lock $arg"
872     set chan [lindex [split $arg] 0]
873     if {$chan == "-all"} {
874     if {![matchattr $hand $sl_lockflags]} {
875     putidx $idx "You're not global +$sl_lockflags." ; return 0
876     }
877     set locklist ""
878     foreach chan [channels] {
879     if {(([botonchan $chan]) && ([botisop $chan]))} {
880     putquick "MODE $chan +mi"
881     lappend locklist $chan
882     }
883     }
884     putidx $idx "Locked [join $locklist ", "]"
885     } else {
886     if {$chan == ""} {
887     set chan [lindex [console $idx] 0]
888     }
889     if {![validchan $chan]} {
890     putidx $idx "No such channel." ; return 0
891     } elseif {![matchattr $hand $sl_lockflags|$sl_lockflags $chan]} {
892     putidx $idx "You're not +$sl_lockflags on $chan." ; return 0
893     } elseif {![botonchan $chan]} {
894     putidx $idx "I'm not on $chan" ; return 0
895     } elseif {![botisop $chan]} {
896     putidx $idx "I'm not opped on $chan" ; return 0
897     }
898     putquick "MODE $chan +mi"
899     putidx $idx "Locked $chan"
900     }
901     return 0
902     }
903    
904     proc sl_dccuc {hand idx arg} {
905     global sl_lockflags
906     putcmdlog "#$hand# unlock $arg"
907     set chan [lindex [split $arg] 0]
908     if {$chan == "-all"} {
909     if {![matchattr $hand $sl_lockflags]} {
910     putidx $idx "You're not global +$sl_lockflags." ; return 0
911     }
912     set locklist ""
913     foreach chan [channels] {
914     if {(([botonchan $chan]) && ([botisop $chan]))} {
915     putserv "MODE $chan -mi"
916     lappend locklist $chan
917     }
918     }
919     putidx $idx "Unlocked [join $locklist ", "]"
920     } else {
921     if {$chan == ""} {
922     set chan [lindex [console $idx] 0]
923     }
924     if {![validchan $chan]} {
925     putidx $idx "No such channel." ; return 0
926     } elseif {![matchattr $hand $sl_lockflags|$sl_lockflags $chan]} {
927     putidx $idx "You're not +$sl_lockflags on $chan." ; return 0
928     } elseif {![botonchan $chan]} {
929     putidx $idx "I'm not on $chan" ; return 0
930     } elseif {![botisop $chan]} {
931     putidx $idx "I'm not opped on $chan" ; return 0
932     }
933     putserv "MODE $chan -mi"
934     putidx $idx "Unlocked $chan"
935     }
936     return 0
937     }
938    
939     proc sl_dcc {hand idx arg} {
940     global sl_avflood sl_ban sl_banmax sl_bcflood sl_boban sl_boflood sl_bmflood sl_bxsimul sl_bfmaxbans sl_ccflood sl_globalban sl_igtime sl_jflood sl_kicks sl_lockcmds sl_lockflags sl_ilocktime sl_mlocktime sl_nkflood sl_note sl_shortlock sl_txflood
941     putcmdlog "#$hand# sentinel $arg"
942     putidx $idx "This bot is protected by sentinel.tcl by slennox"
943     putidx $idx "Current settings"
944     if {[lsearch -exact $sl_bcflood 0] != -1} {
945     putidx $idx "- Bot CTCP flood: Off"
946     } else {
947     putidx $idx "- Bot CTCP flood: [lindex $sl_bcflood 0] in [lindex $sl_bcflood 1] secs"
948     }
949     if {[lsearch -exact $sl_bmflood 0] != -1} {
950     putidx $idx "- Bot MSG flood: Off"
951     } else {
952     putidx $idx "- Bot MSG flood: [lindex $sl_bmflood 0] in [lindex $sl_bmflood 1] secs"
953     }
954     if {[lsearch -exact $sl_ccflood 0] != -1} {
955     putidx $idx "- Channel CTCP flood: Off"
956     } else {
957     putidx $idx "- Channel CTCP flood: [lindex $sl_ccflood 0] in [lindex $sl_ccflood 1] secs"
958     }
959     if {[lsearch -exact $sl_avflood 0] != -1} {
960     putidx $idx "- Channel AVALANCHE flood: Off"
961     } else {
962     putidx $idx "- Channel AVALANCHE flood: [lindex $sl_avflood 0] in [lindex $sl_avflood 1] secs"
963     }
964     if {[lsearch -exact $sl_txflood 0] != -1} {
965     putidx $idx "- Channel TEXT flood: Off"
966     } else {
967     putidx $idx "- Channel TEXT flood: [lindex $sl_txflood 0] in [lindex $sl_txflood 1] secs"
968     }
969     if {[lsearch -exact $sl_boflood 0] != -1} {
970     putidx $idx "- Channel BOGUS flood: Off"
971     } else {
972     putidx $idx "- Channel BOGUS flood: [lindex $sl_boflood 0] in [lindex $sl_boflood 1] secs"
973     }
974     if {[lsearch -exact $sl_jflood 0] != -1} {
975     putidx $idx "- Channel JOIN-PART flood: Off"
976     } else {
977     putidx $idx "- Channel JOIN-PART flood: [lindex $sl_jflood 0] in [lindex $sl_jflood 1] secs"
978     }
979     if {[lsearch -exact $sl_nkflood 0] != -1} {
980     putidx $idx "- Channel NICK flood: Off"
981     } else {
982     putidx $idx "- Channel NICK flood: [lindex $sl_nkflood 0] in [lindex $sl_nkflood 1] secs"
983     }
984     if {!$sl_ilocktime} {
985     putidx $idx "- Channel +i locktime: Indefinite"
986     } else {
987     putidx $idx "- Channel +i locktime: $sl_ilocktime secs"
988     }
989     if {!$sl_mlocktime} {
990     putidx $idx "- Channel +m locktime: Indefinite"
991     } else {
992     putidx $idx "- Channel +m locktime: $sl_mlocktime secs"
993     }
994     if {(($sl_shortlock) && ($sl_ban))} {
995     putidx $idx "- Small flood short lock: Active"
996     } else {
997     putidx $idx "- Small flood short lock: Inactive"
998     }
999     if {(($sl_ban) && ($sl_ban < 120))} {
1000     putidx $idx "- Channel flood bans: $sl_ban mins"
1001     } elseif {$sl_ban >= 120} {
1002     putidx $idx "- Channel flood bans: [expr $sl_ban / 60] hrs"
1003     } else {
1004     putidx $idx "- Channel flood bans: Disabled"
1005     }
1006     if {((!$sl_boban) || ([lsearch -exact $sl_boflood 0] != -1))} {
1007     putidx $idx "- Bogus username bans: Disabled"
1008     } elseif {(($sl_boban > 0) && ($sl_boban < 120))} {
1009     putidx $idx "- Bogus username bans: $sl_boban mins"
1010     } elseif {$sl_boban >= 120} {
1011     putidx $idx "- Bogus username bans: [expr $sl_boban / 60] hrs"
1012     }
1013     if {(($sl_ban) || ([lsearch -exact $sl_boflood 0] == -1))} {
1014     if {$sl_globalban} {
1015     putidx $idx "- Ban type: Global"
1016     } else {
1017     putidx $idx "- Ban type: Channel-specific"
1018     }
1019     }
1020     if {(($sl_ban) || ([lsearch -exact $sl_boflood 0] == -1))} {
1021     putidx $idx "- Maximum bans: $sl_banmax"
1022     }
1023     if {(($sl_igtime > 0) && ($sl_igtime < 120))} {
1024     putidx $idx "- Flooder ignores: $sl_igtime mins"
1025     } elseif {$sl_igtime >= 120} {
1026     putidx $idx "- Flooder ignores: [expr $sl_igtime / 60] hrs"
1027     } else {
1028     putidx $idx "- Flooder ignores: Permanent"
1029     }
1030     if {$sl_ban} {
1031     putidx $idx "- Kicks per line: $sl_kicks"
1032     }
1033     if {!$sl_bfmaxbans} {
1034     putidx $idx "- Maximum channel bans: Disabled"
1035     } else {
1036     putidx $idx "- Maximum channel bans: $sl_bfmaxbans"
1037     }
1038     if {$sl_note != ""} {
1039     putidx $idx "- Flood notification: Notifying [join $sl_note ", "]"
1040     } else {
1041     putidx $idx "- Flood notification: Off"
1042     }
1043     if {!$sl_lockcmds} {
1044     putidx $idx "- Public lc/uc commands: Disabled"
1045     } elseif {$sl_lockcmds == 1} {
1046     putidx $idx "- Public lc/uc commands: Enabled (+$sl_lockflags users, ops not required)"
1047     } elseif {$sl_lockcmds == 2} {
1048     putidx $idx "- Public lc/uc commands: Enabled (+$sl_lockflags users, ops required)"
1049     }
1050     if {$sl_bxsimul} {
1051     putidx $idx "- BitchX simulation: On"
1052     } elseif {!$sl_bxsimul} {
1053     putidx $idx "- BitchX simulation: Off"
1054     }
1055     return 0
1056     }
1057    
1058     if {$sl_bxsimul} {
1059     bind raw - 001 sl_bxserverjoin
1060     if {![info exists sl_bxonestack]} {
1061     set sl_bxonestack 0
1062     }
1063     if {![info exists sl_bxversion]} {
1064     set sl_bxversion [lindex {75p1+ 75p3+} [rand 2]]
1065     }
1066     set sl_bxsystem "*IX" ; set sl_bxwhoami $username ; set sl_bxmachine ""
1067     catch {set sl_bxsystem [exec uname -s -r]}
1068     catch {set sl_bxwhoami [exec id -un]}
1069     catch {set sl_bxmachine [exec uname -n]}
1070     set sl_bxjointime [unixtime]
1071     proc sl_bxserverjoin {from keyword arg} {
1072     global sl_bxjointime sl_bxisaway
1073     set sl_bxjointime [unixtime] ; set sl_bxisaway 0
1074     return 0
1075     }
1076     proc sl_bxaway {} {
1077     global sl_bxjointime sl_bxisaway
1078     if {!$sl_bxisaway} {
1079     puthelp "AWAY :is away: (Auto-Away after 10 mins) \[\002BX\002-MsgLog [lindex {On Off} [rand 2]]\]"
1080     set sl_bxisaway 1
1081     } else {
1082     puthelp "AWAY"
1083     set sl_bxisaway 0 ; set sl_bxjointime [unixtime]
1084     }
1085     if {![string match *sl_bxaway* [timers]]} {
1086     timer [expr [rand 300] + 10] sl_bxaway
1087     }
1088     return 0
1089     }
1090     if {![info exists sl_bxisaway]} {
1091     set sl_bxisaway 0
1092     }
1093     if {![string match *sl_bxaway* [timers]]} {
1094     timer [expr [rand 300] + 10] sl_bxaway
1095     }
1096     }
1097    
1098     proc sl_setarray {chan} {
1099     global botnick sl_avbanhost sl_avbannick sl_avqueue sl_bfull sl_bobanhost sl_bobannick sl_boqueue sl_ccbanhost sl_ccbannick sl_ccqueue sl_flooded sl_jbanhost sl_jbannick sl_jqueue sl_locked sl_nkbanhost sl_nkflooding sl_nkqueue sl_pbanhost sl_pbannick sl_pqueue sl_txqueue sl_unlocked
1100     set chan [string tolower $chan]
1101     sl_killutimer "incr sl_*queue($chan) -1"
1102     sl_killutimer "sl_*banqueue $chan"
1103     set sl_flooded($chan) 0 ; set sl_locked($chan) 0 ; set sl_unlocked($chan) [unixtime]
1104     set sl_nkflooding($chan) [unixtime]
1105     set sl_ccqueue($chan) 0 ; set sl_ccbanhost($chan) "" ; set sl_ccbannick($chan) ""
1106     set sl_avqueue($chan) 0 ; set sl_avbanhost($chan) "" ; set sl_avbannick($chan) ""
1107     set sl_txqueue($chan) 0
1108     set sl_nkqueue($chan) 0 ; set sl_nkbanhost($chan) ""
1109     set sl_boqueue($chan) 0 ; set sl_bobanhost($chan) "" ; set sl_bobannick($chan) ""
1110     set sl_jqueue($chan) 0 ; set sl_jbanhost($chan) "" ; set sl_jbannick($chan) ""
1111     set sl_pqueue($chan) 0 ; set sl_pbanhost($chan) "" ; set sl_pbannick($chan) ""
1112     set sl_bfull($chan) 0
1113     return 0
1114     }
1115    
1116     proc sl_settimer {} {
1117     foreach chan [channels] {
1118     sl_setarray $chan
1119     }
1120     return 0
1121     }
1122    
1123     proc sl_killutimer {cmd} {
1124     set n 0
1125     regsub -all -- {\[} $cmd {\[} cmd ; regsub -all -- {\]} $cmd {\]} cmd
1126     foreach tmr [utimers] {
1127     if {[string match $cmd [join [lindex $tmr 1]]]} {
1128     killutimer [lindex $tmr 2]
1129     incr n
1130     }
1131     }
1132     return $n
1133     }
1134    
1135     if {((![info exists sl_unlocked]) && (![string match *sl_settimer* [utimers]]))} {
1136     utimer 3 sl_settimer
1137     }
1138    
1139     if {![info exists sl_bflooded]} {
1140     set sl_bflooded 0
1141     }
1142     if {![info exists sl_bcqueue]} {
1143     set sl_bcqueue 0
1144     }
1145     if {![info exists sl_bmqueue]} {
1146     set sl_bmqueue 0
1147     }
1148     if {![info exists sl_nickkick]} {
1149     set sl_nickkick 0
1150     }
1151    
1152     set sl_bcflood [split $sl_bcflood :] ; set sl_bmflood [split $sl_bmflood :]
1153     set sl_ccflood [split $sl_ccflood :] ; set sl_avflood [split $sl_avflood :]
1154     set sl_txflood [split $sl_txflood :] ; set sl_boflood [split $sl_boflood :]
1155     set sl_jflood [split $sl_jflood :] ; set sl_nkflood [split $sl_nkflood :]
1156     set sl_note [split $sl_note]
1157    
1158     if {(($sl_ilocktime > 0) && ($sl_ilocktime < 30))} {
1159     set sl_ilocktime 30
1160     }
1161     if {(($sl_mlocktime > 0) && ($sl_mlocktime < 30))} {
1162     set sl_mlocktime 30
1163     }
1164    
1165     set trigger-on-ignore 0
1166     if {!${kick-method}} {
1167     set sl_kicks 8
1168     } else {
1169     set sl_kicks ${kick-method}
1170     }
1171    
1172     if {$numversion >= 1032100} {
1173     set kick-bogus 0
1174     }
1175     if {$numversion >= 1032400} {
1176     set ban-bogus 0 ; set kick-fun 0 ; set ban-fun 0
1177     }
1178     if {$numversion >= 1032500} {
1179     set ctcp-mode 0
1180     }
1181    
1182     if {((![string match *sl_txqueuereset* [utimers]]) && ([lsearch -exact $sl_txflood 0] == -1))} {
1183     utimer [lindex $sl_txflood 1] sl_txqueuereset
1184     }
1185    
1186     bind pub $sl_lockflags|$sl_lockflags lc sl_lc
1187     bind pub $sl_lockflags|$sl_lockflags uc sl_uc
1188     bind dcc $sl_lockflags|$sl_lockflags lock sl_dcclc
1189     bind dcc $sl_lockflags|$sl_lockflags unlock sl_dccuc
1190     if {!$sl_lockcmds} {
1191     unbind pub $sl_lockflags|$sl_lockflags lc sl_lc
1192     unbind pub $sl_lockflags|$sl_lockflags uc sl_uc
1193     }
1194     bind dcc m|m sentinel sl_dcc
1195     bind raw - NOTICE sl_avflood
1196     bind raw - PRIVMSG sl_avflood
1197     if {(([lsearch -exact $sl_avflood 0] != -1) && ([lsearch -exact $sl_txflood 0] != -1))} {
1198     unbind raw - NOTICE sl_avflood
1199     unbind raw - PRIVMSG sl_avflood
1200     }
1201     bind ctcp - CLIENTINFO sl_ctcp
1202     bind ctcp - USERINFO sl_ctcp
1203     bind ctcp - VERSION sl_ctcp
1204     bind ctcp - FINGER sl_ctcp
1205     bind ctcp - ERRMSG sl_ctcp
1206     bind ctcp - ECHO sl_ctcp
1207     bind ctcp - INVITE sl_ctcp
1208     bind ctcp - WHOAMI sl_ctcp
1209     bind ctcp - OP sl_ctcp
1210     bind ctcp - OPS sl_ctcp
1211     bind ctcp - UNBAN sl_ctcp
1212     bind ctcp - PING sl_ctcp
1213     bind ctcp - TIME sl_ctcp
1214     bind msgm - * sl_bmflood
1215     if {[lsearch -exact $sl_bmflood 0] != -1} {unbind msgm - * sl_bmflood}
1216     bind nick - * sl_nkflood
1217     if {[lsearch -exact $sl_nkflood 0] != -1} {unbind nick - * sl_nkflood}
1218     bind join - * sl_jflood
1219     bind part - * sl_pflood
1220     bind kick - * sl_pfloodk
1221     bind flud - * sl_flud
1222     bind mode - * sl_mode
1223    
1224     putlog "Loaded sentinel.tcl v2.00 by slennox"
1225    
1226     return

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23