egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

adding join flood check

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Zircon
Op


Joined: 21 Aug 2006
Posts: 191
Location: Montreal

PostPosted: Thu Oct 18, 2007 5:28 pm    Post subject: adding join flood check Reply with quote

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
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Sat Oct 20, 2007 8:07 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Zircon
Op


Joined: 21 Aug 2006
Posts: 191
Location: Montreal

PostPosted: Mon Oct 22, 2007 3:39 am    Post subject: Reply with quote

Hello De Kus

Thanks a lot for your help, and clear explanations. I appreciate, really. I ll do what you advised me. Thanks again Smile
Back to top
View user's profile Send private message
droolin
Halfop


Joined: 24 Jul 2003
Posts: 64

PostPosted: Sun Nov 04, 2007 10:58 pm    Post subject: Thank you also Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber