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.
Help for those learning Tcl or writing their own scripts.
r6gear
Voice
Posts: 3 Joined: Wed Nov 23, 2022 9:28 am
Post
by r6gear » Wed Nov 23, 2022 9:31 am
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!))"
}
simo
Revered One
Posts: 1100 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Wed Nov 23, 2022 4:15 pm
Code: Select all
# 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.
CrazyCat
Revered One
Posts: 1277 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Wed Nov 23, 2022 7:01 pm
@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 ?
r6gear
Voice
Posts: 3 Joined: Wed Nov 23, 2022 9:28 am
Post
by r6gear » Wed Nov 23, 2022 7:25 pm
simo wrote: Code: Select all
# 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
simo
Revered One
Posts: 1100 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Thu Nov 24, 2022 12:26 am
That's true i overlooked that thanks for pointing out CrazyCat
r6gear
Voice
Posts: 3 Joined: Wed Nov 23, 2022 9:28 am
Post
by r6gear » Thu Nov 24, 2022 10:14 am
it's posibile to add a option every user to have let's say 1 shoot every 30 seconds?
CrazyCat
Revered One
Posts: 1277 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Thu Nov 24, 2022 11:45 am
Just add the nick in the key of Xthrottled. That is what I pointed previously.
Code: Select all
# 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"
}