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 

need help - flood code - random wait time

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Diamond85
Voice


Joined: 25 Oct 2008
Posts: 27

PostPosted: Sat Jan 12, 2013 3:13 pm    Post subject: need help - flood code - random wait time Reply with quote

Hello EggHelp user! I need help again ...
I want a flood code.
three times that a user can use the command.
then he must wait one random time of under 30 seconds minimum and maximum 3Minutes..
Important: (the person should not be ignored but the command can not use).
it should be a variable available for the command, for example:

# How often can use
varaible maxuse "3"


is that possible?


with my code that I have, I will not work: (

Code:

  variable command_char "!"
 
 # set these to your preferred binds
  variable command_bind "Join_Counter"
 
 # how many requests in how many seconds is considered flooding?
 # by default, this allows 2 queries in 60 seconds, the 3th being wait
  variable flood_limit "2:60"
 
 # number of wait seconds for the flooder
 # "0" - disable wait, "60" - the flooder must wait 60 seconds
  variable wait_time "60"
 
 # set here the admin flags (m=Master / n=Owner / o=OP ...)
 # to enable or disable this script on channel commands
  variable user_flags "+mno|+mno"
 
 # set here the default language
 # "en" - english, "de" - german
  variable text_lang "de"
 
 # set here the nicks are not to be added to database
  variable no_nicks "*guest*"
 
  # set here to channel record default on / off
  variable chan_record "on"


Code:

 #############################################################################
 #                                Flood Check                                #
 #############################################################################
  proc fc_check {nick host hand chan arg} {
   if {[channel get $chan Join_Counter]} {
    if {[Join_Counter::fa_flood $nick $host $hand $chan $arg]} {
     return
    }
    Join_Counter::sa_action2 $nick $host $hand $chan $arg
   }
  }
 #############################################################################
 #                               Flood Action                                #
 #############################################################################
  variable fa_data
  variable fa_array
  proc fa(init) {} {
   foreach chan [channels] {
    if {![string match *:* [channel get $chan Join_Counter-Flood]]} {
     if {[channel get $chan Join_Counter-Lang] == "en"} {
      putlog "\[14Join_Counter 04Error\] 14variable \(09flood_limit: 09[channel get $chan Join_Counter-Flood]) 14is not set correctly."
      return 1
     }
         if {[channel get $chan Join_Counter-Lang] == "de"} {
      putlog "\[14Join_Counter 04Error\] 14variable \(09flood_limit: 09[channel get $chan Join_Counter-Flood]) 14wurde nicht richtig Eingestellt."
      return 1
     }
    }
    set Join_Counter::fa_data(flood_num) [lindex [split [channel get $chan Join_Counter-Flood] :] 0]
    set Join_Counter::fa_data(flood_time) [lindex [split [channel get $chan Join_Counter-Flood] :] 1]
    set i [expr $Join_Counter::fa_data(flood_num) - 1]
    while {$i >= 0} {
     set Join_Counter::fa_array($i) 0
     incr i -1
    }
   }
  }
  ; fa(init)
  proc fa_flood {nick host hand chan arg} {
   if {$Join_Counter::fa_data(flood_num) == 0} {
    return 0
   }
   set i [expr ${Join_Counter::fa_data(flood_num)} - 1]
   while {$i >= 1} {
    set Join_Counter::fa_array($i) $Join_Counter::fa_array([expr $i - 1])
    incr i -1
   }
   set Join_Counter::fa_array(0) [unixtime]
   if {[expr [unixtime] - $Join_Counter::fa_array([expr ${Join_Counter::fa_data(flood_num)} - 1])] <= ${Join_Counter::fa_data(flood_time)}} {
    Join_Counter::wa_action $nick $host $hand $chan $arg
    return 1
   } else {
    return 0
   }
  }
 #############################################################################
 #                               Wait Action                                 #
 #############################################################################
  proc wa_action {nick host hand chan arg} {
   if {[set timeleft [Join_Counter::wa_throttled $host,$chan [channel get $chan Join_Counter-Wait]]]} {
    if {[channel get $chan Join_Counter-Lang] == "en"} {
     putnow "PRIVMSG $chan :\[14Join_Counter 04Flood Protection\] 09You 14can only again in 04$timeleft 14seconds!"
    }
    if {[channel get $chan Join_Counter-Lang] == "de"} {
     putnow "PRIVMSG $chan :\[14Join_Counter 04Flood Protection\] 09Du 14darfst erst wieder in 04$timeleft 14Sekunden!"
    }
   } else {
    Join_Counter::sa_action2 $nick $host $hand $chan $arg
   }
  }
  proc wa_throttled {id time} {
   global wa_throttled
   if {[info exists wa_throttled($id)]} {
    return [expr {($wa_throttled($id)+$time)-[clock sec]}] 
   } {
    set wa_throttled($id) [clock sec]
    utimer $time [list unset wa_throttled($id)]
    return 0
   }
  }



the whole script I have here has 1069 lines so I'd rather not post this Smile
Link to TCL on Pastebin

sorry for my bad english
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests 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