mIRC Home    About    Download    Register    News    Help

Print Thread
anti-flood #264779 11/01/19 06:04 PM
Joined: Nov 2018
Posts: 6
R
raven Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Nov 2018
Posts: 6
Can someone help me with a anti-flood? I have a simple trigger:

on 1:TEXT:hello*:#:/say $chan Welcome to $chan $nick!

But I want a flood protection to that, restricting it to one line every 10 seconds..

Re: anti-flood [Re: raven] #264780 11/01/19 07:06 PM
Joined: Jan 2004
Posts: 1,187
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,187
Are you wanting to reply only if you have not replied within the past 10 seconds?
Or have a queue window that stores up your replies and eventually spits them out at 10 seconds intervals?

If the former, see this thread.

If the latter, it can quickly get complicated if you need to track nick changes or if the target has even remained in the channel.

Re: anti-flood [Re: maroon] #264794 12/01/19 01:13 PM
Joined: Nov 2018
Posts: 6
R
raven Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Nov 2018
Posts: 6
on !1:TEXT:Hello:#mychan:{
if (!%comwait) {
set -u10 %comwait 1
Hey $nick
}
else echo Flood triggered, 10 seconds cooldown
}

Would that give me a 10 seconds cooldown?

Re: anti-flood [Re: raven] #264800 13/01/19 03:05 AM
Joined: Jan 2004
Posts: 1,187
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,187
For "reason", you usually want to use *:TEXT instead of 1:TEXT

You don't need the ! prefix in :TEXT: event which targets a channel, because your own messages in a #channel never trigger the :TEXT: event.

It does set a cooldown that affects everyone. As shown in the link I gave above, you can have a separate cooldown per nick and another cooldown for the channel as a whole.

It's a good idea to have variables which are unlikely to be trampled on by other scripts. If this is just for #mychan, then name the variable %comwait.#mychan

If I were to do this, I'd also use a variable name which didn't look like it was being used in a $com, $comcall, or a sock* event. %cooldown.#mchan would probably be better for when you look at this script for the first time in 6 months.

Unless you have an alias named "Hey", that will be an invalid command that gets sent to the server to see if it recognizes HEY either.