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.

Request songs limit to 2 songs per person

Support & discussion of released scripts, and announcements of new releases.
User avatar
mabrook
Halfop
Posts: 60
Joined: Mon Jun 14, 2021 9:41 am

Post by mabrook »

script in first post updated...
User avatar
flink
Halfop
Posts: 83
Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias

Re: Limit requests to 2 per nick per 15 minutes

Post by flink »

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: 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  }
  }
}

Then add this line to the top of each request process you would like to limit...

Code: Select all

  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: 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.
Mi ingles: no es el mejor, Manda el traductor... :)
Post Reply