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 

adding flood protections to this

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


Joined: 23 Nov 2022
Posts: 3

PostPosted: Wed Nov 23, 2022 9:31 am    Post subject: adding flood protections to this Reply with quote

i want to add flood protection to this script. if a user want can user !love !love ...etc and floods the channel.
Can anyoane help me adding ? thank you

bind pub - !love fun_give-love

proc fun_give-love {nick uhost hand chan text} {
putserv "privmsg $chan :\001ACTION Lui 5$nick gives 5$text love!))"
}
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Wed Nov 23, 2022 4:15 pm    Post subject: Reply with quote

Code:



# throttle time in seconds
set Xthrottled(time) 10


proc throttlecheckerX {chan} {
  global Xthrottled
    if {[info exists Xthrottled($chan)]} {
       return 1
   } else {
      set Xthrottled($chan) [utimer $::Xthrottled(time) [list unset Xthrottled($chan)]]
      return 0
   }
}
 
bind pub - !love fun_give-love

proc fun_give-love {nick uhost hand chan text} {
     if {[throttlecheckerX $chan]} { return 0 }
         set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
         set items [split $text]
     if {[llength $items] < 1 } { putnow "notice $nick :Syntax\: !love nick" ; return }
          set lovenick [lindex [split $text] 0]
         putserv "privmsg $chan :\001ACTION  \002\00305,00 $nick \002\00312 gives \00306\002 $lovenick \002\00307 love \003\017"
}



Last edited by simo on Thu Nov 24, 2022 8:53 am; edited 2 times in total
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1108
Location: France

PostPosted: Wed Nov 23, 2022 7:01 pm    Post subject: Reply with quote

@simo : so the command could only be used once every 10s on the chan, whoever use it ?
Why throttlecheckerX has nick as argument if it's not used ?
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
r6gear
Voice


Joined: 23 Nov 2022
Posts: 3

PostPosted: Wed Nov 23, 2022 7:25 pm    Post subject: Reply with quote

simo wrote:
Code:



# throttle time in seconds
set Xthrottled(time) 10


proc throttlecheckerX {nick chan} {
  global Xthrottled
    if {[info exists Xthrottled($chan)]} {
       return 1
   } else {
      set Xthrottled($chan) [utimer $::Xthrottled(time) [list unset Xthrottled($chan)]]
      return 0
   }
}
 
bind pub - !love fun_give-love

proc fun_give-love {nick uhost hand chan text} {
     if {[throttlecheckerX $nick $chan]} { return 0 }
         set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
         set items [split $text]
     if {[llength $items] < 1 } { putnow "notice $nick :Syntax\: !love nick" ; return }
          set lovenick [lindex [split $text] 0]
         putserv "privmsg $chan :\001ACTION  \002\00305,00 $nick \002\00312 gives \00306\002 $lovenick \002\00307 love \003\017"
}



Thank you for helping! !beer
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Thu Nov 24, 2022 12:26 am    Post subject: Reply with quote

That's true i overlooked that thanks for pointing out CrazyCat 👍
Back to top
View user's profile Send private message
r6gear
Voice


Joined: 23 Nov 2022
Posts: 3

PostPosted: Thu Nov 24, 2022 10:14 am    Post subject: Reply with quote

it's posibile to add a option every user to have let's say 1 shoot every 30 seconds?
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1108
Location: France

PostPosted: Thu Nov 24, 2022 11:45 am    Post subject: Reply with quote

Just add the nick in the key of Xthrottled. That is what I pointed previously.
Code:
# throttle time in seconds
set Xthrottled(time) 10

proc throttlecheckerX {nick chan} {
   global Xthrottled
   if {[info exists Xthrottled($chan,$nick)]} {
      return 1
   } else {
      set Xthrottled($chan,$nick) [utimer $::Xthrottled(time) [list unset Xthrottled($chan,$nick)]]
      return 0
   }
}
 
bind pub - !love fun_give-love

proc fun_give-love {nick uhost hand chan text} {
     if {[throttlecheckerX $nick $chan]} { return 0 }
         set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
         set items [split $text]
     if {[llength $items] < 1 } { putnow "notice $nick :Syntax\: !love nick" ; return }
          set lovenick [lindex [split $text] 0]
         putserv "privmsg $chan :\001ACTION  \002\00305,00 $nick \002\00312 gives \00306\002 $lovenick \002\00307 love \003\017"
}

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
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