mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2005
Posts: 15
D
dtrmp4 Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Feb 2005
Posts: 15
Note: I'm a newbie, I know it should be easy, since the title of the script is "simple flood protection".

Anyways, this is the script:
Code:
 on *:start: { 
  ;if user sends more than %flood.lines in this time ban them 
  set %flood.unset 3
  ;if a user sends more than this many lines/actions in %flood.unset ban them 
  set %flood.lines 5 
  ;this is the bantime in seconds 
  set %flood.bantime 600
} 
ON @*:TEXT:*:#: { 
  if ($nick !isop $chan) { 
    inc $($+(-u,%flood.unset)) $+(%,flood.,$chan,.,text.,$nick) 
    if ($($+(%,flood.,$chan,.,text.,$nick),2) >= %flood.lines) { 
      ban $($+(-ku,%flood.bantime)) $chan $nick 3 Don't flood 
    } 
  } 
} 
ON @*:ACTION:*:#: { 
  if ($nick !isop $chan) { 
    inc $($+(-u,%flood.unset)) $+(%,flood.,$chan,.,action.,$nick) 
    if ($($+(%,flood.,$chan,.,action.,$nick),2) >= %flood.lines) { 
      ban $($+(-ku,%flood.bantime)) $chan $nick 3 Don't flood 
    } 
  } 
}  


Basically, I want it to kick/time ban (for 10 minutes) someone from #theoutboards if they say 7 lines in 10 seconds.

How would I do this?

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Im gonna assume the code actually works correctly in the two events, and your problem was just with how many in how much time, and limiting it to the said channel.

[edit]
I dont think this does work now i look at it, the %,flood.,$chan,.,text.,$nick well keep being incremented even if the user is only saying one thing eveery two seconds, becuase the new -u10 setting well take effect each time, so im adding a -z to the /INC commands to cause the number to count down 1 per second, im not really sure if that is perfectly fair, but would seem to be better than just not reseting the count, someone could say something every 2 seconds and on the 7th time it would kick them, thats 7 lines in 14 seconds, so thatrs not fair either!


Code:
 on *:start: { 
  ;if user sends more than %flood.lines in this time ban them 
  set %flood.unset 10
  ;if a user sends more than this many lines/actions in %flood.unset ban them 
  set %flood.lines 7 
  ;this is the bantime in seconds 
  set %flood.bantime 600
} 
ON @*:TEXT:*:#theoutboards: { 
  if ($nick !isop $chan) { 
    inc $($+(-zu,%flood.unset)) $+(%,flood.,$chan,.,text.,$nick) 
    if ($($+(%,flood.,$chan,.,text.,$nick),2) >= %flood.lines) { 
      ban $($+(-ku,%flood.bantime)) $chan $nick 3 Don't flood 
    } 
  } 
} 
ON @*:ACTION:*:#theoutboards: { 
  if ($nick !isop $chan) { 
    inc $($+(-zu,%flood.unset)) $+(%,flood.,$chan,.,action.,$nick) 
    if ($($+(%,flood.,$chan,.,action.,$nick),2) >= %flood.lines) { 
      ban $($+(-ku,%flood.bantime)) $chan $nick 3 Don't flood 
    } 
  } 
}  


oh and if you wanted it to be a combined total of text and actions, replace the action event with

Code:
ON @*:ACTION:*:#theoutboards: { 
  if ($nick !isop $chan) { 
    inc $($+(-zu,%flood.unset)) $+(%,flood.,$chan,.,text.,$nick) 
    if ($($+(%,flood.,$chan,.,text.,$nick),2) >= %flood.lines) { 
      ban $($+(-ku,%flood.bantime)) $chan $nick 3 Don't flood 
    } 
  } 
}


Last edited by DaveC; 20/02/05 11:08 PM.
Joined: Feb 2005
Posts: 15
D
dtrmp4 Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Feb 2005
Posts: 15
Yea, that's what I had when I was testing it, so I assume the script doesn't work.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Sorry I was editing the reply when you replied to it, try it now.

Joined: Feb 2005
Posts: 15
D
dtrmp4 Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Feb 2005
Posts: 15
Nope. Still doesn't work.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Thats a tad indescriptive, what doesnt work about it? (remember i havent run this myself, but i guess i well now)

Does it kick people who havent said too much?
Does it not kick anyone?
Does it delete your hard drive each time its run?

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
ON @*:TEXT:*:#theoutboards: {
  if ($nick !isop $chan) { 
    inc $($+(-zu,%flood.unset)) $+(%,flood.,$chan,.,text.,$nick) %flood.unset
    if ($($+(%,flood.,$chan,.,text.,$nick),2) > $calc(%flood.lines * %flood.unset)) { 
      ban $($+(-ku,%flood.bantime)) $chan $nick 3 Don't flood 
    } 
  } 
} 
ON @*:ACTION:*:#theoutboards: { 
  if ($nick !isop $chan) { 
    inc $($+(-zu,%flood.unset)) $+(%,flood.,$chan,.,action.,$nick) %flood.unset
    if ($($+(%,flood.,$chan,.,action.,$nick),2) > $calc(%flood.lines * %flood.unset)) { 
      ban $($+(-ku,%flood.bantime)) $chan $nick 3 Don't flood 
    } 
  } 
}

* i corrected the >= to being a > as it ment to be more than X number of lines, not X or more.

This is what i came up with

Each time someone says soemthing it adds the number of seconds allowed (10 in your case) to there total, thats how long the lines valid for, its also how long the total well reflect anypart of that line, as the total decreases by 1 per second. (hope that makes sence).

If there over (number of lines allowed x total seconds allowed) (7 x 10 in your case) there baned.

If they dont say anything in number of seconds allowed (7 in your case) there total is reset to zero, so that fixes the accumulating problem.

Ex. say someone says 6 lines all at once there total would be 60, 5 seconds later its 55, they then say 1 line its up to 67, still under 70, if they say anything in the next 7 seconds, as there total drops from 67 to 60 then 10 would be added and there over 70, and get banned.

*** Im sure I have missed something in the logic here but its monday and it eludes me , as do most things on a monday **

Joined: Feb 2005
Posts: 15
D
dtrmp4 Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Feb 2005
Posts: 15
Now it kick bans when I just say 1 thing.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Forget all that rubbish i said above, its still got a huge flaw in it, this well work for what you want just as you wanted.
Code:
on *:start: { 
  ;if user sends more than %flood.lines in this time ban them 
  set %flood.unset 10
  ;if a user sends more than this many lines/actions in %flood.unset ban them 
  set %flood.lines 7 
  ;this is the bantime in seconds 
  set %flood.bantime 600
} 
ON @*:TEXT:*:#theoutboards: {
  if ($nick !isop $chan) { 
    set $($+(-u,%flood.unset)) $+(%,flood.,$chan,.text.,$nick,.,$ticks,.,$rand(1001,1999)) .
    echo -st - $+(%,flood.,$chan,.text.,$nick,.*) - $var($+(%,flood.,$chan,.text.,$nick,.*))
    if ($var($+(%,flood.,$chan,.text.,$nick,.*)) > %flood.lines) { 
      ban $($+(-ku,%flood.bantime)) $chan $nick 3 Don't flood 
    } 
  } 
} 
ON @*:ACTION:*:#theoutboards: { 
  if ($nick !isop $chan) { 
    set $($+(-u,%flood.unset)) $+(%,flood.,$chan,.action.,$nick,.,$ticks,.,$rand(1001,1999)) .
    if ($var($+(%,flood.,$chan,.action.,$nick,.*)) > %flood.lines) { 
      ban $($+(-ku,%flood.bantime)) $chan $nick 3 Don't flood 
    } 
  } 
}

I just make a random varaiable as follows %flood.$chan.text.$nick.number.number which unsets itself in 10 seconds
Then just see if there are more than 7 of them, if so ban em!

remember to replace the ON ACTION script with the ON TEXT script if you want it to be acumulitive between both types of text. (see in the ON ACTION where it says .action. replace both of them with .text.)

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
lol, did you remove the ON START event?
It was ment to be left in, i just didnt show it becuase it was the same as before.

Anyway i replaced it all with something that works as requested to now.

Joined: Feb 2005
Posts: 15
D
dtrmp4 Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Feb 2005
Posts: 15
Still doesn't work, now it's just not kicking period.

EDIT: Just relized I'm getting this after each line said:
- %flood.#theoutboards.text.Rodney.* - 1
- %flood.#theoutboards.text.Rodney.* - 1
- %flood.#theoutboards.text.Rodney.* - 1
- %flood.#theoutboards.text.Rodney.* - 1

Last edited by dtrmp4; 21/02/05 10:26 AM.
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Try this, main difference is it uses a hash table except for the 3 settings.
Make sure the other is gone completely
Code:
on *:start: {
  ;if user sends more than %flood.lines in this time ban them
  set %flood.unset 10
  ;if a user sends more than this many lines/actions in %flood.unset ban them
  set %flood.lines 6
  ;this is the bantime in seconds
  set %flood.bantime 600
}
on @*:text:*:#theoutboards:{
  if ($nick !isop $chan) { _floodchk text. }
}
on @*:action:*:#theoutboards:{
  if ($nick !isop $chan) { _floodchk action. }
}
alias -l _floodchk {
  hinc -mz $+(flood.,#) $+($1,$site) %flood.unset
  if ($hget($+(flood.,#),$+($1,$site)) > $calc(%flood.lines * %flood.unset)) {
    ban $+(-ku,%flood.bantime) # $nick 3 Don't flood
    hdel -w $+(flood.,#) $+(*.,$site)
  }
}



Although I'd not differentiate between action and text. Consider...
[03:35:15] * User something
[03:35:16] <User> text
[03:35:17] * User action
[03:35:18] <User> text
[03:35:19] <User> text
[03:35:20] * User action
[03:35:21] <User> text
[03:35:22] <User> text
[03:35:23] * User action
[03:35:24] <User> text

That's 10 lines in 9 secs and still no flood kick...

Code:
on *:start: {
  ;if user sends more than %flood.lines in this time ban them
  set %flood.unset 10
  ;if a user sends more than this many lines/actions in %flood.unset ban them
  set %flood.lines 6
  ;this is the bantime in seconds
  set %flood.bantime 600
}
on @*:text:*:#theoutboards:{
  if ($nick !isop $chan) { _floodchk }
}
on @*:action:*:#theoutboards:{
  if ($nick !isop $chan) { _floodchk }
}
alias -l _floodchk {
  hinc -mz $+(flood.,#) $site %flood.unset
  if ($hget($+(flood.,#),$site) &gt; $calc(%flood.lines * %flood.unset)) {
    ban $+(-ku,%flood.bantime) # $nick 3 Don't flood
    hdel $+(flood.,#) $site
  }
}

Joined: Feb 2005
Posts: 15
D
dtrmp4 Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Feb 2005
Posts: 15
Now it's back to banning after 1 line (I used the second script btw)

Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Did you resstart miRC, or manually reset the variables?
Try typing //echo -a %flood.lines / %flood.unset / %flood.bantime

Joined: Feb 2005
Posts: 15
D
dtrmp4 Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Feb 2005
Posts: 15
Alright, it worked. Thanks a lot, both of you.

Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Great smile

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Execelent idea using a hash table, bad idea using my badly concieved increment by seconds and test against secs x lines idea.
I ran it in a channel (i wasnt oped but no @ used in the event and i just ECHO -A BAN etc etc) And every now and then it would say ban so and so, and they hadnt said overly large amount of text. I finally tracked it down to this, ill display it because its hard to explain.

12:00:01 <john> blah ... total = 10
12:00:02 <john> blah ... total = 19
12:00:03 <john> blah ... total = 28
12:00:04 <john> blah ... total = 37
12:00:05 <john> blah ... total = 46
12:00:06 <john> blah ... total = 54
12:00:07 <john> blah ... total = 63
12:00:08 ... total = 62
12:00:09 ... total = 61
12:00:10 ... total = 60
12:00:11 ... total = 59
12:00:12 <john> blah ... total = 69
12:00:12 ... total = 68
12:00:13 ... total = 67
12:00:14 ... total = 66
12:00:15 ... total = 65
12:00:16 <john> blah ... total = 74 *** BAN ****

As you see john only said 3 to 4 lines in the last 10 seconds, thats why i changed to making multiple vars that erased in 10 seconds, then checked how many there were of them.

I also think your right he wasnt restarting so the on start wasnt triggering.

Joined: Feb 2005
Posts: 15
D
dtrmp4 Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Feb 2005
Posts: 15
Yea, I wasn't restarting.

-_-

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
hehehe, I wondered about that

oh those funny lines comming up were from this line
echo -st - $+(%,flood.,$chan,.text.,$nick,.*) - $var($+(%,flood.,$chan,.text.,$nick,.*))
it wasnt ment to be in there, it was a on the spot debugging line i added, so i could watch what was happeing, i didnt notice it when pasted the code into the forum.


Link Copied to Clipboard