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 

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

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


Joined: 19 Dec 2007
Posts: 27

PostPosted: Thu Dec 17, 2009 11:37 am    Post subject: how to set flood control in this script? [[SOLVED]] Reply with quote

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

brak.tcl

Code:
# 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:
#### 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 Very Happy


Last edited by mojado on Tue Jan 12, 2010 2:24 pm; edited 1 time in total
Back to top
View user's profile Send private message
TCL_no_TK
Owner


Joined: 25 Aug 2006
Posts: 509
Location: England, Yorkshire

PostPosted: Fri Dec 18, 2009 5:39 pm    Post subject: Reply with quote

See this post on how to include a "throttle" type system in to the script.
_________________
TCL the misunderstood
Back to top
View user's profile Send private message Send e-mail
mojado
Voice


Joined: 19 Dec 2007
Posts: 27

PostPosted: Mon Jan 04, 2010 9:52 pm    Post subject: Reply with quote

Thanxs for reply.... Smile

The .tcl looks like this?

Code:
# 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... Embarassed

Regards.
Back to top
View user's profile Send private message
TCL_no_TK
Owner


Joined: 25 Aug 2006
Posts: 509
Location: England, Yorkshire

PostPosted: Tue Jan 05, 2010 1:57 am    Post subject: Reply with quote

its ok, great try Very Happy
Code:
 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
   }
}

_________________
TCL the misunderstood
Back to top
View user's profile Send private message Send e-mail
mojado
Voice


Joined: 19 Dec 2007
Posts: 27

PostPosted: Tue Jan 05, 2010 1:01 pm    Post subject: Reply with quote

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

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

BTW, thanxs. Very Happy

Code:
# 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 ..."
Back to top
View user's profile Send private message
TCL_no_TK
Owner


Joined: 25 Aug 2006
Posts: 509
Location: England, Yorkshire

PostPosted: Thu Jan 07, 2010 2:16 am    Post subject: Reply with quote

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

Code:
# 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 ..."

_________________
TCL the misunderstood
Back to top
View user's profile Send private message Send e-mail
mojado
Voice


Joined: 19 Dec 2007
Posts: 27

PostPosted: Tue Jan 12, 2010 2:24 pm    Post subject: Reply with quote

U ar awesome.
My script works fine again!!

Many thanxs TCL.Wink
Back to top
View user's profile Send private message
Elfriede
Halfop


Joined: 07 Aug 2007
Posts: 67

PostPosted: Tue Mar 09, 2010 5:07 pm    Post subject: Reply with quote

Code:

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
Back to top
View user's profile Send private message
TCL_no_TK
Owner


Joined: 25 Aug 2006
Posts: 509
Location: England, Yorkshire

PostPosted: Tue Mar 09, 2010 8:38 pm    Post subject: Reply with quote

Quote:
if {[throttled $host,$chan 10]} {
10 seconds maybe?
_________________
TCL the misunderstood
Back to top
View user's profile Send private message Send e-mail
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Mar 09, 2010 9:45 pm    Post subject: Reply with quote

@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:
...
  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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Elfriede
Halfop


Joined: 07 Aug 2007
Posts: 67

PostPosted: Wed Mar 10, 2010 4:47 am    Post subject: Reply with quote

Many thanks - got it Smile
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 -> 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