|
Joined: Apr 2007
Posts: 9
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Apr 2007
Posts: 9 |
So i have myself set up to message people when they join my channel with MOTD, however if i message more thna 20 people in 120 seconds the irc server stops me for 120 seconds. But i continut to get names put in the log file as people join, but they dont get the message. So i want to use $counter a variable i will define to raise in value once every time i send a message until $counter reaches 20, at this point i want the script to pause for 120 seconds and then clear $counter back to zero and start all over again. Code is as follows below. set -e $counter if ($counter == '20') { pause s 120 dec $counter 20 } else if { on *:join:#:{ if ($read(nicks.txt,w,$+($nick,!*))) return write nicks.txt $+($nick,!)
msg $nick } inc $counter 1 }
alias pause { var %e = !echo $color(info) -a * /pause: if ($version < 5.91) { %e this snippet requires atleast mIRC version 5.91 } elseif ($isid) { %e this snippet can only be called as a command. } elseif (!$regex(pause,$1-,/^m?s \d+$/Si)) { %e incorrect/insufficient parameters. Syntax: /pause <s|ms> <N> } elseif ($1 == ms) && ($os isincs 9598ME) { %e cannot use milliseconds parameter on OS'es beneath Win2k } elseif ($2 !isnum 1-) { %e must specify a number within range 1- } else { var %wsh = $+(wsh,$ticks,$r(1111,9999)), %cmd if ($1 == s) %cmd = ping.exe -n $int($calc($2 + 1)) 127.0.0.1 else %cmd = pathping.exe -n -w 1 -q 1 -h 1 -p $iif($2 > 40,$calc($2 - 40),$2) 127.0.0.1 .comopen %wsh wscript.shell if ($comerr) %e unable to open Wscript.Shell else .comclose %wsh $com(%wsh,run,1,bstr*,% $+ comspec% /c %cmd >nul,uint,0,bool,true) } }
I am sure there ar esome problems with this, which is why i need your help
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
on !*:join:#:{
set -u120 %counter $iif(!%counter,1,$calc(%counter + 1))
.timer 1 %counter .msg $nick <message>
}
I don't know what the Pause alias is for, but the above code doesn't need it.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Just use /inc instead of /set:
on !*:join:#:{
inc -u120 %motd.counter
.timer 1 %motd.counter .msg $nick <message>
}
I also changed the variable name to help prevent possible conflicts. Personally, I'd drop the unset time down to 30s. If someone joins 90s after the last person to enter and is the 60th person to enter without it being reset, there's no reason to wait the 60s to send the message since there has been plenty of time between people to prevent the network/server from "muting" you. You could probably drop it to 10s for that matter. It resets the counter whenever someone joins, so in the case of a netsplit, if 100 people suddenly come in, it will msg them one person at a time with a 1 second interval between each, but if someone enters 11s after all of that, then it would be reset and they would get the message immediately. 10s should be enough so that the network doesn't complain.
Last edited by Riamus2; 20/04/07 12:01 AM.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
I've had inconsistent problems when trying to use inc with a variable that has a $null level, which is why I used the more complicated form. As to the unset delay, you're right, I just didn't consider all of the factors properly when I wrote the code.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Hmm. I've never had an issue with /inc when the variable is $null.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Apr 2007
Posts: 9
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Apr 2007
Posts: 9 |
so would this be the correct modified code to work. Notice i added my own loggin code to make sure i don't double P.M anyone. on !*:join:#:{ if ($read(nicks.txt,w,$+($nick,!*))) return write nicks.txt $+($nick,!) set -u120 %counter $iif(!%counter,1,$calc(%counter + 1)) .timer 1 %counter .msg $nick <message> }
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Personally, I don't see why the log in part is being done that way. I'd do it like this instead.
on !*:join:#:{
if ($read(nicks.txt,w,$nick)) return
write nicks.txt $nick
set -u120 %counter $iif(!%counter,1,$calc(%counter + 1))
.timer 1 %counter .msg $nick <message>
}
I assume it was so that you would not match Tim with Timothy or whatever... but the method above works fine for that because it will only match the exact nick because we're using w (wildcard) and no wildcards. If we used s instead of w, then it would search for $nick*, which we wouldn't want and which I think your log in script was trying to avoid.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Apr 2007
Posts: 9
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Apr 2007
Posts: 9 |
now its not sending the message, how long should it take befor ei see the message get sent?
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
If you're looking for verification that the message has been sent by using the client that the code is on, remove the . from the .msg section of the timer line. That . is called a full stop, and makes the outgoing message silent (ie: it doesn't show on the client sending the message). This does not affect the person receiving the message.
|
|
|
|
|