| View previous topic :: View next topic |
| Author |
Message |
CyBaH Voice
Joined: 06 Aug 2007 Posts: 3 Location: emmen, The Netherlands
|
Posted: Mon Aug 06, 2007 1:59 pm Post subject: prevent public command abuse with a timer on a user |
|
|
Hi all,
I tried to use the search function but could not really find the right search keywords i assume.
I am having the problem that ppl are able to use a trigger(public command like !test) at any moment.
I would like to let my bot look if the user allready used the !test trigger in the last for example 1 minute.
any suggestions where to search / how to add it ?
| Code: | bind pub -|- !test test:test
proc test:test {nick uhost hand channel arg} {
putserv "PRIVMSG $channel : text i want to send by trigger"
}
|
so again..bot has to remember the user allready used the trigger in the last minute.
I must say i have some tcl knowledge but this i could not find.
Thanks and i hope i wrote in the correct forum
CyBaH
[/code] |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon Aug 06, 2007 3:33 pm Post subject: |
|
|
Simplest way, I suppose, would be to save a timestamp for the last time each user used the command. You'd probably have to use handle-names or implement some method of keeping track of who's who (nickchanges, etc).
As one later on triggers the command, check wether the timestamp is old enough to determine wether it should be permitted or not. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Mon Aug 06, 2007 6:10 pm Post subject: |
|
|
| Sir_Fz wrote: | | Search the forum for the keyword 'throttled'. |
I think that old proc is ready for an upgrade:
| Code: | proc throttled {id time} {
global throttled
if {[info exists throttled($id)]} {
return 1
} {
set throttled($id) [utimer $time [list unset throttled($id)]]
return 0
}
} |
...making better use of the variable - That way, you can clean things up a little easier, if you ever need to:
| Code: | proc killthrottle id {
global throttled
if {[info exists throttled($id)]} {
killutimer $throttled($id)
unset throttled($id)
}
} |
_________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
BoaR Halfop
Joined: 20 Jul 2007 Posts: 48
|
Posted: Mon Aug 06, 2007 10:37 pm Post subject: |
|
|
This should work also..
| Code: | #set time in seconds to wait after the user can use the command.
set antiflood "10"
variable flood
proc {} {
if {![info exists flood($chan)]} {set flood($chan) 0}
if {[unixtime] - $flood($chan) <= $antiflood} {return}
set flood($chan) [unixtime]
code here...
} |
|
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Tue Aug 07, 2007 7:25 am Post subject: |
|
|
| BoaR wrote: | This should work also..
| Code: | #set time in seconds to wait after the user can use the command.
set antiflood "10"
variable flood
proc {} {
if {![info exists flood($chan)]} {set flood($chan) 0}
if {[unixtime] - $flood($chan) <= $antiflood} {return}
set flood($chan) [unixtime]
code here...
} |
|
Try to follow what your code does and see if it is what CyBaH wants.
Here's an example using user's proc:
| Code: | bind pub -|- !test test:test
proc test:test {nick uhost hand channel arg} {
if {![throttled $uhost:$channel 60]} {
putserv "PRIVMSG $channel : text i want to send by trigger"
}
}
proc throttled {id time} {
global throttled
if {[info exists throttled($id)]} {
return 1
} {
set throttled($id) [utimer $time [list unset throttled($id)]]
return 0
}
} |
This allows using !test only once every 60 seconds for user@host on every channel. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
CyBaH Voice
Joined: 06 Aug 2007 Posts: 3 Location: emmen, The Netherlands
|
Posted: Tue Aug 07, 2007 2:05 pm Post subject: |
|
|
Much thanks for the replies, i will try to implant it and see how it works
much thanks so far
CyBaH
HappY |
|
| Back to top |
|
 |
CyBaH Voice
Joined: 06 Aug 2007 Posts: 3 Location: emmen, The Netherlands
|
Posted: Wed Aug 08, 2007 5:33 am Post subject: |
|
|
much thanks again
it works great o/
CyBaH |
|
| Back to top |
|
 |
|