mIRC Home    About    Download    Register    News    Help

Print Thread
#168138 04/01/07 11:03 AM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
Code:
on *:text:!rose*:#:{
  msg # $nick gives $2 a bunch roses showing his/her love.
}


I made a simple commands on my bot
but some users are using it like hell
can anyone pls make a anti flood on this simple code
thanks


learn learn learn
Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
Code:
on *:text:!rose*:#:{

  ; Set your anti-flood configuration here.
  ; I've set it to ignore an user for 300 seconds (5 minutes)
  ; if (s)he says "!rose" for at least 3 times in 5 seconds.
  var %lines = 3, %secs = 5, %ignore = 300

  var %id = $+(%,flood.,$cid,$site,#)

  inc $iif(!$var($(%id)),-u $+ %secs) $(%id)
  if ($(%id,2) >= %lines) {
    .ignore -cu $+ %ignore $nick 4
    .notice $nick Anti-flood: you're now ignored for $duration(%ignore)
  }
  else { msg # $nick gives $2 a bunch roses showing his/her love. }
}


Please note that I haven't tested the code.


* cold edits his posts 24/7
Joined: Dec 2006
Posts: 80
Babel fish
Offline
Babel fish
Joined: Dec 2006
Posts: 80
A simple flood control....

Code:
 
on *:text:!rose*:#:{
  if (%rose) halt
  set -u5 %rose 1
  msg # $nick gives $2 a bunch roses showing his/her love.
}


This sets the control, then allows it to be messaged once. The bot ignores the trigger while %rose exists. Which in this case -u5 is 5 seconds, you can set that to any increment in seconds, 10, 15, 60, 300 seconds if you so choose.


Scripto ---- Life is about the relationships. The correct code being: $replace($them,$you,$me)
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
That's the way I usually do it as well, though using return instead of halt is a preferable way to stop a script's execution. The other example is a nicer way that lets the user who flooded know that he/she was ignored. It all depends what you want to have happen. With the ignore, that user can't use any commands for the bot during that time period and it affects just that one person. With the other method, no one can use this one command during the time perdiod and the nick who flooded would still be able to use other commands. The downside that I see with ignoring one nick as a method of flood prevention is that a lot of clones can still flood you off with that one command.


Invision Support
#Invision on irc.irchighway.net
Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
Originally Posted By: Riamus2
The downside that I see with ignoring one nick as a method of flood prevention is that a lot of clones can still flood you off with that one command.


Yeah, I realized that too. It's possible, though, to implement a 2nd flood detection that's directed "globally" and let it interact with the "personal" one. However, I feel that maybe the code is too complex as it is (I can't stop myself complicating these things, lol)... I guess I'd prefer the simpler way.


* cold edits his posts 24/7

Link Copied to Clipboard