SpiKe^^ wrote:This code should limit script requests to 2 per nick for any 15 minute period
First add all of this code to the bottom of your script...Then add this line to the top of each request process you would like to limit...Code: Select all
proc too_many {nick uhost hand arg} { global toomany set nk [string tolower $nick] set ut [unixtime] set nowls [list] if {[info exists toomany($nk)]} { foreach expire $toomany($nk) { if {$ut < $expire} { lappend nowls $expire } } } set toomany($nk) $nowls if {[llength $nowls] >= 2} { putserv "notice $nick :No more than 2 requests in 15 minutes!" return 1 } lappend toomany($nk) [expr {$ut + (60 * 15)}] return 0 } bind cron - {*/10 * * * *} expire_too_many proc expire_too_many {mn hr da mo wd} { global toomany set ut [unixtime] foreach {aname avalue} [array get toomany] { set nowls [list] foreach expire $avalue { if {$ut < $expire} { lappend nowls $expire } } if {![llength $nowls]} { unset toomany($aname) } else { set toomany($aname) $nowls } } }
In "Tido's Modified Icecast2 Script", you have 2 request procs you will want to modify:Code: Select all
if {[too_many $nick $uhost $hand $arg]} { return 0 }
proc request (for public requests)
and:
proc request_pm (for private message requests)
That would make the beginning of your 2 request procs look something like this...Code: Select all
proc request {nick uhost hand chan arg} { if {[too_many $nick $uhost $hand $arg]} { return 0 } global dj if {$dj != ""} {
This all untested, please let me know how it all works out.