View previous topic :: View next topic |
Author |
Message |
mabrook Halfop

Joined: 14 Jun 2021 Posts: 60
|
Posted: Thu Sep 22, 2022 11:56 am Post subject: |
|
|
script in first post updated... |
|
Back to top |
|
 |
flink Halfop

Joined: 21 Feb 2021 Posts: 70 Location: Canarias
|
Posted: Sat Jan 07, 2023 8:10 am Post subject: Re: Limit requests to 2 per nick per 15 minutes |
|
|
I need help with this part of the script:
putserv "warning $nick: No more than 2 requests in 15 minutes!" You could add how much time is left before you can reapply, example:
putserv "notice $nick: No more than 2 requests in 15 minutes! you have to wait 6 minutes to be able to requesting again"
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... Code: |
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 }
}
}
|
Then add this line to the top of each request process you would like to limit... Code: |
if {[too_many $nick $uhost $hand $arg]} { return 0 }
|
In "Tido's Modified Icecast2 Script", you have 2 request procs you will want to modify:
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: |
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. |
_________________ Mi ingles: no es el mejor, Manda el traductor...  |
|
Back to top |
|
 |
|
|
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
|
|