| View previous topic :: View next topic |
| Author |
Message |
Zircon Op
Joined: 21 Aug 2006 Posts: 191 Location: Montreal
|
Posted: Thu Oct 18, 2007 5:28 pm Post subject: adding join flood check |
|
|
Hi all
I think i ll have more chance here. I have this little script that send a notice to everyone joining the channel. I want to prevent the bot from being laggued or disconnected when there is a join flood. I want to modify this script so the bot stop sending notices for 1 min, when there is 3 joins (or more) in 1 second. How can i do it ?
| Code: | bind join -|- * join_culture
proc join_culture {nick host hand chan} {
if {$chan == "#culture"} {
puthelp "NOTICE $nick :tapez !help dans #culture pour avoir la liste des commandes"
}
} |
Thanks in advance |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Sat Oct 20, 2007 8:07 am Post subject: |
|
|
Theoretically using puthelp is quite a good methode to prevent floodings. However too many putquick scritps often screw this.
I use a little helper for anti-flood protections I wrote myself.
| Code: | # # # # # # # # #
# decrease
# usage : decrease <var>
# return : 0 or 1 (can be discarded)
#
# info : usefull for save var decreasings, var cannot drop below 0 and no
# TCL error can occure
#
proc decrease {var} {
if {[info exists ::$var]} {
if {[set ::$var] <= 1} {
set ::$var 0
} else {
incr ::$var -1
}
return 0
} else {
putlog "decrease: Variable '$var' doesn't exist"
return 1
}
} |
You should now create a global variable containing a counter check for this before you send the stuff. An abstract example would be:
| Code: | set example_c 0
proc example {nick host hand chan} {
if {$::example_c < 3} {
incr $::example_c
utimer 1 {decrease example_c}
#do stuff here
}
return 0
} |
Some explanations:
- The helper function is used to avoid the variable to drop below 0 due to .rehash while there is a timer running
- The parameter to the helper function must be the variable name, not the variable content.
- the constants 3 and 1 in the above example reflect allowed executions x within the timespan y seconds. Note that 1 second can never be accurate, since utimer triggers on full seconds, therefore the actual timespan x is: 0s < x < 1s _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
Zircon Op
Joined: 21 Aug 2006 Posts: 191 Location: Montreal
|
Posted: Mon Oct 22, 2007 3:39 am Post subject: |
|
|
Hello De Kus
Thanks a lot for your help, and clear explanations. I appreciate, really. I ll do what you advised me. Thanks again  |
|
| Back to top |
|
 |
droolin Halfop

Joined: 24 Jul 2003 Posts: 64
|
Posted: Sun Nov 04, 2007 10:58 pm Post subject: Thank you also |
|
|
I can see that bit of code being used for a few things that I've been planing to do, just never had an idea how to go about it.
droolin |
|
| Back to top |
|
 |
|