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 

Request songs limit to 2 songs per person
Goto page Previous  1, 2
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
mabrook
Halfop


Joined: 14 Jun 2021
Posts: 60

PostPosted: Thu Sep 22, 2022 11:56 am    Post subject: Reply with quote

script in first post updated...
Back to top
View user's profile Send private message
flink
Halfop


Joined: 21 Feb 2021
Posts: 70
Location: Canarias

PostPosted: Sat Jan 07, 2023 8:10 am    Post subject: Re: Limit requests to 2 per nick per 15 minutes Reply with quote

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... 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 -> Script Support & Releases All times are GMT - 4 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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