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.

trigger commands antiflood

Help for those learning Tcl or writing their own scripts.
Post Reply
y
yozeff
Voice
Posts: 2
Joined: Wed Jan 09, 2008 1:06 pm

trigger commands antiflood

Post by yozeff »

Hello.

It's my first post :) I have searched through the forum, but could not find such thing:

if a user on the channel very quickly types 3 lines:

[10:05:15] <user> !kiss Nickname
[10:05:15] <user> !kiss Nickname
[10:05:16] <user> !kiss Nickname

...then bot does this:

[10:05:18] <bot> user kisses Nickname :)
[10:05:18] <bot> user kisses Nickname :)
[10:05:19] <bot> user kisses Nickname :)

What I want is: if user types command !kiss quickly 3 or even 5 times then bot says text only 1 time. How to accomplish that?

Thank You!

Here's my code (hope it will be posted correctly, because of my first post):

Code: Select all

bind pub - !kiss pub_kiss

proc pub_kiss {nick host handle channel testes} {

set who [lindex $testes 0]
if { $who == "" } {
utimer 3 [ list putquick "PRIVMSG $channel $nick does not knows who to kiss" ]
return 1
}

utimer 3 [ list putquick "PRIVMSG $channel $nick kisses $who :)" ]
return 1
}
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

Could try using a 'throttle' type system. Take a look at this post
y
yozeff
Voice
Posts: 2
Joined: Wed Jan 09, 2008 1:06 pm

trigger commands antiflood [solved]

Post by yozeff »

Thanks! Problem solved! I combined scripts like this:

Code: Select all

bind pub - !kiss pub:kiss 

proc throttled {id time} {
   global throttled
   if {[info exists throttled($id)]} {
      return 1
   } {
      set throttled($id) [clock sec]
      utimer $time [list unset throttled($id)]
      return 0
   }
}

proc pub:kiss {nick uhost handle channel a} { 
set who [lindex $a 0] 

if {[throttled $uhost,$channel 3]} {
return 1
} elseif {
$who == "" } { 
puthelp "PRIVMSG $channel $nick does not knows who to kiss" 
return 1
} else {
puthelp "PRIVMSG $channel $nick kisses $who :)" 
return 1
}
}
And now it works!

Thanks TCL_no_TK
Post Reply