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 

prevent public command abuse with a timer on a user

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


Joined: 06 Aug 2007
Posts: 3
Location: emmen, The Netherlands

PostPosted: Mon Aug 06, 2007 1:59 pm    Post subject: prevent public command abuse with a timer on a user Reply with quote

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
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon Aug 06, 2007 3:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon Aug 06, 2007 5:10 pm    Post subject: Reply with quote

Search the forum for the keyword 'throttled'.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Mon Aug 06, 2007 6:10 pm    Post subject: Reply with quote

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
View user's profile Send private message
BoaR
Halfop


Joined: 20 Jul 2007
Posts: 48

PostPosted: Mon Aug 06, 2007 10:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Aug 07, 2007 7:25 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
CyBaH
Voice


Joined: 06 Aug 2007
Posts: 3
Location: emmen, The Netherlands

PostPosted: Tue Aug 07, 2007 2:05 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
CyBaH
Voice


Joined: 06 Aug 2007
Posts: 3
Location: emmen, The Netherlands

PostPosted: Wed Aug 08, 2007 5:33 am    Post subject: Reply with quote

much thanks again

it works great o/

CyBaH
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