mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2014
Posts: 107
M
Majeye Offline OP
Vogon poet
OP Offline
Vogon poet
M
Joined: Jan 2014
Posts: 107
Trying to figure out how to create an on text command that will respond to someone posting "!play" in a channel, and respond also with "!play", but will add a flood protection for the command itself that lasts 120 seconds (2 minutes).

I used to mess around with mIRC coding years ago, and can't for the life of me remember any of it. lol

I know it starts out something like:

Code
ON *:TEXT:*!play*:#:(
      This is where I'm lost
}

Any and all help appreciated, or even nudges in the right direction. Trying to figure this stuff out again!

Last edited by Majeye; 22/02/23 05:29 AM.
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
search the forum for keyword cooldown, there are many posts in this topic, including
https://forums.mirc.com/ubbthreads....a-user-cooldown-for-my-script#Post268425

Joined: Jan 2014
Posts: 107
M
Majeye Offline OP
Vogon poet
OP Offline
Vogon poet
M
Joined: Jan 2014
Posts: 107
So, I'm using the following, but would also like to add a flood protection to the command/on:text itself. Tried to search for it, and though I've found a few items on it, it doesn't make much sense to me. Anyone can clarify it a bit, or help me at all would be most appreciated.

Code
ON *:TEXT:*!play*:#:{
  if (!$ialmark($nick,$+($chan,.greeted))) {
    .ialmark -n $nick $+($chan,.greeted) 1
    .timer 1 $rand(2,5) msg $unsafe($chan !play)

    ;== Uncomment below to make it trigger only once per nick within 600ms...
    $+(.timer,$chan,.,$nick) 1 180 .ialmark -rn $nick $+($chan,.greeted)
  }
}

Could something like this work instead?

Code
on $*:text:/(!play)$/i:#: {
  if ((%flood) || ($($+(%,flood.,$nick),2))) { return } && ($nick == nick)
  set -u180 %flood On
  set -u220 %flood. $+ $nick On
  { msg $chan !play }
}

Last edited by Majeye; 22/02/23 07:15 PM.
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
The ialmark you're using is basically like the hashtable in the threads I mentioned.
But unfortunately the ialmark is not always as robust as hashtables are. For example, your method requires a timer to unset the ialmark after N seconds. In a hashtable, the item can be easily saved-to-disk loaded-from-disk matched with wildcards created with limited lifetime etc. The 1 big advantage the ialmark has is that the tag follows them when they change nick. Unfortunately the timer is still going to perform a command against a nick that doesn't exist anymore

You can have a hashtable with items that cool down the 1 nick for 30 sec
hadd -mu30 table $+(greet.,$nick) 1
or
hadd -z table $+(greet.,$nick) 30
then in the on text event
if ($hget(table,$+(greet.,$nick)) goto ignore-this

To handle during a nick change, the latter makes it a little easier, since the item value has the countdown time in it, so in the ON NICK event:
if ($hget(table,$+(greet.,$nick)) {

hadd -z table $+(greet.,$newnick) $v1
hdel table $+(greet.,$nick)
}

The above applies to each nick across all channels and all networks, so to prevent collisions, the itemname would need to be named something like
$+(greet.$network,$chan,.,$nick)

for a per channel global you just have it be an item named

$+(greet.$network,$chan)

Since ialmark is taking care of by having a separate $ial per network, you just put an ialmark on yourself that's checked against everyone

$ialmark($me,$+($chan,.greeted)

.ialmark -n $me $+($chan,.greeted) 1

Obligatory reminder that $ial has the behavior that each time you get disconnected that the IAL vanishes, and so do all the marks, which is fine for this use case. However the ialmark also goes away each time that nick no longer shares any channels with you. So that means if you get kicked from your only channel, then $ial is now empty and all marks are gone. Likewise if the 1 person /part the only channel they share with you, the ialmark goes byebye along with their address in the $ial

Joined: Jan 2014
Posts: 107
M
Majeye Offline OP
Vogon poet
OP Offline
Vogon poet
M
Joined: Jan 2014
Posts: 107
maroon, that is SUPER helpful. Thank you so very much! Appreciate it a lot!


Link Copied to Clipboard