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.

How to Ignore a trigger from a specific user for 3mns ?

Old posts that have not been replied to for several years.
Locked
S
Sibelius
Voice
Posts: 3
Joined: Tue Jan 18, 2005 11:29 pm

How to Ignore a trigger from a specific user for 3mns ?

Post by Sibelius »

Hello.
I run a tcl script which answers users ctcp triggers.
I wonder how to make the script ignore a trigger from one specific user for a 3 mns period.

Thanks in advance.

Sibelius
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Code: Select all

newignore hostmask creator comment ?lifetime?
S
Sibelius
Voice
Posts: 3
Joined: Tue Jan 18, 2005 11:29 pm

Post by Sibelius »

Tks MeTroiD.

In fact, I dont want to ignore user completely.
I would need to only ignore his ctcp search trigger for some time but allow him to do other things with the bot.

I guess your solution totally ignore the user.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

something like this?

Post by user »

Code: Select all

proc throttled {id seconds} {
	global throttle
	if {[info exists throttle($id)]&&$throttle($id)>[clock sec]} {
		set id 1
	} {
		set throttle($id) [expr {[clock sec]+$seconds}]
		set id 0
	}
}
# delete expired entries every 10 minutes
bind time - ?0* throttledCleanup
proc throttledCleanup args {
	global throttle
	set now [clock sec]
	foreach {id time} [array get throttle] {
		if {$time<=$now} {unset throttle($id)}
	}
}
...or using timers to do the cleanup

Code: Select all

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
	}
}
example limiting usage by same user@host on a specific channel
(the id part can be what ever you like of course)

Code: Select all

bind pub n !test pub:test
proc pub:test {n u h c a} {
	if {[throttled $u,$c 30]} {
		puthelp "PRIVMSG $c :$n: denied. (wait or try a different channel)"
	} else {
		puthelp "PRIVMSG $c :$n: allowed (wait 30 seconds)"
	}
}
Have you ever read "The Manual"?
S
Sibelius
Voice
Posts: 3
Joined: Tue Jan 18, 2005 11:29 pm

Post by Sibelius »

User,

Many Thanks for your very complete solution !
Locked