This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

how to set flood control in this script? [[SOLVED]]

Help for those learning Tcl or writing their own scripts.
Post Reply
m
mojado
Voice
Posts: 27
Joined: Wed Dec 19, 2007 10:29 am

how to set flood control in this script? [[SOLVED]]

Post by mojado »

Hi everyone, I have a litle doubt...how to set flood control in this tcl??

brak.tcl

Code: Select all

# brak Quotes 1.0 by maximopc. 29/08/09
#
#
bind pub - !brak pub_brak
proc pub_brak {nick mask hand channel args} {
   global brak
   puthelp "PRIVMSG $channel :[lindex $brak [rand [llength $brak]]]"
   }


set brak {

"\"cuando algo ilegal se hace publico se transforma automaticamente en virus, aunque no los sea, Hay muchos programas que no son virus, sin embargo, como son maliciosos, les ponen la caratula de troyano.\""
"\"esas cosas apenas las llega a las manos de lamers, lo meten en virustotal. y cagó.\""
"\"niños, cuando ustedes hacen un troyano, y agarra alguien y se da cuenta que es un troyano, y le rompe las bolas agarra el archivo. Lo comprime pone examiniar (similar a tinypic para que entiendan) y de ahí se fijan expertos, y si es le hacen un HASH o MD5 y se carga como virus en la mayoria de los antivirus.\""
"\"na, todo pasado.. troyano prestado.. muy lamer el asunto.. me fuí.\""
"\"cojanse una mina hagan algo loco, dejense de games.\""
"\"cuando tenía tu edad Cry_Wolf^Aw en esta epoca andaba en pedo metido en una carpa con 5 minas.\""
"\"pequeña matraca le estoy dando a la impresora, hasta que no queme el cartucho no paro.\""
"\"estoy registrado en cualquier server.\""
"\"anda muy tranquilo ColiFa, que te pasa andas turvado?.\""
"\"si tienen vehiculo gasolero o naftero.. llenen el tanque.\""
"\"yo si no se algo, digo.. [bueno no lo se], no digo que me comió la tarea el perro.\""
"\"no SrWeT lo mio es el cracking.\""
"\"haganlé una vaquita para la silicona.\""
}

putlog "brak Quotes 1.0 by maximopc loaded ..."
I like something llike this......

Code: Select all

#### FLOOD CONTROL
  
  # Antiflood (0 = off, 1 = on)
  variable antiflood 1
  # Individual antiflood control
  # "6:30" = maximum 6 commands per 30 seconds; following ones will be ignored.
  variable cmdflood_addquote "3:80"
  variable cmdflood_quote "5:80"
  variable cmdflood_quoteinfo "5:80"
  variable cmdflood_delquote "2:60"
  variable cmdflood_randquote "5:80"
  variable cmdflood_lastquote "2:60"
  variable cmdflood_findquote "3:80"
  # global antiflood control (all commands)
  # please note : for the maximum allowed number of commands, make sure the
  #               value is greater than the greatest value defined for
  #               the individual antiflood control settings.
  variable cmdflood_global "10:120"
  # Minimum time interval between 2 warning messages from the antiflood.
  # Do not set that value too low or you will be flooded by antiflood warnings ;)
  variable antiflood_msg_interval 20
Thanxs in advance people. :wink: :D
Last edited by mojado on Tue Jan 12, 2010 2:24 pm, edited 1 time in total.
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

See this post on how to include a "throttle" type system in to the script.
m
mojado
Voice
Posts: 27
Joined: Wed Dec 19, 2007 10:29 am

Post by mojado »

Thanxs for reply.... :)

The .tcl looks like this?

Code: Select all

# brak Quotes 1.0 by maximopc. 29/08/09
#
#
bind pub - !brak pub_brak
proc pub_brak {nick mask hand channel args} {
   global brak
   puthelp "PRIVMSG $channel :[lindex $brak [rand [llength $brak]]]"
   }

bind pub n !brak pub:brak
proc pub:brak {n u h c a} {
   if {[throttled $u,$c 30]} {
      puthelp "PRIVMSG $c :$n: denied. (wait or try a different channel)"
   } else {
      puthelp "PRIVMSG $c :$n: allowed (wait 30 seconds)"
   }
}
Sorry for ask... :oops:

Regards.
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

its ok, great try :D

Code: Select all

 bind pub -|- !brak pub:brak

 proc pub:brak {nick host hand chan text} {
  global brak
   if {[throttled $u,$c 30]} {
     return 0
   } else {
    puthelp "PRIVMSG $chan :[lindex $brak [rand [llength $brak]]]"
    return 1
   }
 }

proc throttled {id time} {
   global throttled
   if {[info exists throttled($id)]} {
      return 1
   } {
      set throttled($id) [clock sec]
      utimer $time [list unset throttled($id)]
      return 0
   }
}
m
mojado
Voice
Posts: 27
Joined: Wed Dec 19, 2007 10:29 am

Post by mojado »

Many thanxs for your help TCL_no_TK... but this tcl doesn´t work anymore. :?

So weird. It´s loaded, but when type !brak in channel not work.

BTW, thanxs. :D

Code: Select all

# brak Quotes 1.0 by maximopc. 29/08/09
#
#
bind pub - !chuck pub_brak
proc pub_brak {nick mask hand channel args} {
   global brak
   puthelp "PRIVMSG $channel :[lindex $brak [rand [llength $brak]]]"
   }

bind pub -|- !brak pub:brak

 proc pub:brak {nick host hand chan text} {
  global brak
   if {[throttled $u,$c 30]} {
     return 0
   } else {
    puthelp "PRIVMSG $chan :[lindex $brak [rand [llength $brak]]]"
    return 1
   }
 }

proc throttled {id time} {
   global throttled
   if {[info exists throttled($id)]} {
      return 1
   } {
      set throttled($id) [clock sec]
      utimer $time [list unset throttled($id)]
      return 0
   }
}


set brak {



"\"cuando algo ilegal se hace publico se transforma automaticamente en virus, aunque no los sea, Hay muchos programas que no son virus, sin embargo, como son maliciosos, les ponen la caratula de troyano.\""

"\"esas cosas apenas las llega a las manos de lamers, lo meten en virustotal. y cagó.\""

"\"niños, cuando ustedes hacen un troyano, y agarra alguien y se da cuenta que es un troyano, y le rompe las bolas agarra el archivo. Lo comprime pone examiniar (similar a tinypic para que entiendan) y de ahí se fijan expertos, y si es le hacen un HASH o MD5 y se carga como virus en la mayoria de los antivirus.\""

"\"na, todo pasado.. troyano prestado.. muy lamer el asunto.. me fuí.\""
}

putlog "brak Quotes 1.0 by maximopc loaded ..."
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

I lowered the throttled time as well, so they only have to wait 10 seconds before they can use the !brak again :)

Code: Select all

# brak Quotes 1.0 by maximopc. 29/08/09
#
#

 bind pub -|- !brak pub:brak

 proc pub:brak {nick uhost hand chan text} {
  global brak
   set host [lindex [split $uhost @] 1]
   if {[throttled $host,$chan 10]} {
     return 0
   } else {
    puthelp "PRIVMSG $chan :[lindex $brak [rand [llength $brak]]]"
    return 1
   }
 }

proc throttled {id time} {
   global throttled
   if {[info exists throttled($id)]} {
      return 1
   } {
      set throttled($id) [clock sec]
      utimer $time [list unset throttled($id)]
      return 0
   }
}

set brak {
"\"cuando algo ilegal se hace publico se transforma automaticamente en virus, aunque no los sea, Hay muchos programas que no son virus, sin embargo, como son maliciosos, les ponen la caratula de troyano.\""
"\"esas cosas apenas las llega a las manos de lamers, lo meten en virustotal. y cagó.\""
"\"niños, cuando ustedes hacen un troyano, y agarra alguien y se da cuenta que es un troyano, y le rompe las bolas agarra el archivo. Lo comprime pone examiniar (similar a tinypic para que entiendan) y de ahí se fijan expertos, y si es le hacen un HASH o MD5 y se carga como virus en la mayoria de los antivirus.\""
"\"na, todo pasado.. troyano prestado.. muy lamer el asunto.. me fuí.\""
"\"cojanse una mina hagan algo loco, dejense de games.\""
"\"cuando tenía tu edad Cry_Wolf^Aw en esta epoca andaba en pedo metido en una carpa con 5 minas.\""
"\"pequeña matraca le estoy dando a la impresora, hasta que no queme el cartucho no paro.\""
"\"estoy registrado en cualquier server.\""
"\"anda muy tranquilo ColiFa, que te pasa andas turvado?.\""
"\"si tienen vehiculo gasolero o naftero.. llenen el tanque.\""
"\"yo si no se algo, digo.. [bueno no lo se], no digo que me comió la tarea el perro.\""
"\"no SrWeT lo mio es el cracking.\""
"\"haganlé una vaquita para la silicona.\""
}

putlog "brak Quotes 1.0 by maximopc loaded ..."
m
mojado
Voice
Posts: 27
Joined: Wed Dec 19, 2007 10:29 am

Post by mojado »

U ar awesome.
My script works fine again!!

Many thanxs TCL.;)
E
Elfriede
Halfop
Posts: 67
Joined: Tue Aug 07, 2007 4:21 am

Post by Elfriede »

Code: Select all

proc pub:brak {nick uhost hand chan text} {
  global brak
   set host [lindex [split $uhost @] 1]
   if {[throttled $host,$chan 10]} {
putserv "PRIVMSG $chan : Flood Control - Retry in xx Seconds" 
   } else {
    puthelp "PRIVMSG $chan :[lindex $brak [rand [llength $brak]]]"
    return 1
   }
 } 
Can someone please add how much time left, till cmd is again possible ? Thank you
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

if {[throttled $host,$chan 10]} {
10 seconds maybe?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

@Elfriede:
Assuming you are using the throttled proc from the previous posts, that shouldn't be too hard. First get the timestamp stored in ::throttled(id), where id is the unique identifier (in your case $host,$chan). Next get the current timestamp using clock seconds. Finally do some simple maths - subtract the old timestamp from the current, and you should get a rough estimate on how long your user needs to wait.

Code: Select all

...
  if {[throttled $host,$chan 10]} {
    #then is $::throttled($host,$chan)
    #now is [clock seconds]
    #time remaining is now - then -> [expr [clock seconds] - $::throttled($host,$chan)]
    puthelp "PRIVMSG $chan : Flood control - Retry in [expr [clock seconds] - $::throttled($host,$chan)] seconds"
  } else {
...
Another way of doing it would be to fetch the list of currently running timers (using the utimers command), search for the timer that's supposed to unset ::throttled(id), and fetch the remaining counter..
NML_375
E
Elfriede
Halfop
Posts: 67
Joined: Tue Aug 07, 2007 4:21 am

Post by Elfriede »

Many thanks - got it :)
Post Reply