mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2021
Posts: 91
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 91
greetz gentz,

i was curious how this small alias could be modified to send messages to chanops in the fashion of

privmsg nick,nick,nick,nick,nick message

we wanted to limit it to stacked packets of nicks of like 5 per line

so like if 10 nicks to send in 2 lines of 5

Code
 
Alias OP1 {
  set %c $nick($chan,0)
  set %i 1
  while (%i <= %c) {
    if ($nick(#,%i,@%)) {
      privmsg $nick(#,%i,@%)  00,14 $1- 
      inc %i 1
    }
    else {
      inc %i 1
    }
  }
}



current code sends privmsg to 1 nick per line

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
Code
alias OP1 {
  var %n 1,%r
  while ($nick($chan,%n,@%)) {
    %r = $addtok(%r,$v1,44)
    if ($numtok(%r,44) == 5) {
      privmsg %r 00,14 $1- 
      unset %r
    }
    inc %i 1
  }
  if (%r) privmsg %r 00,14 $1- 
}


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
This does it more efficiently by avoiding the need to loop through all the non-ops. Without testing, I don't know how the 512 limit is applied to messages when the target of the privmsg is a long list of nicks. I deleted one of the 0's from 00 since it's not needed, and that byte might be needed for the message.

I also changed so it won't send a message to yourself. I also .silenced the PRIVMSG so the display can be simplified to a single echo-to-self instead of potentially dozens of similar lines. The %flag is used to make sure that it doesn't echo-to-self more than once, and it won't echo if you're the only op/halfop.

The internal if() is less efficient, by forcing N loops to evaluate the if() each time. The only reason to keep the if() instead of letting the final while() handle everything is if the list of ops could be so long that it exceeds $maxlenl.

Note how my use of $nick() is more inclusive, as your original would not see nicks who had the & or ~ status without also having the @ or % status too. a=include all, rv=exclude voices and those with no status at all. $nick() lets you use the status symbol and the switch letters interchangeably, so using 'o' and '@' are interchangeable. The exception is prefix 'a' for level & since 'a' is already mapped to 'all nicks'.

Using this kind of alias should also be accompanied by checkboxing "own messages" in flood controls, for obvious reasions.

However, if your network supports the alternate target format, which I believe is indicated by the 005 numeric containing something similar to STATUSMSG=@%+ you should instead use a group target, since it's much more friendly to flood controls:

op1 { notice @% $+ $chan $1- }

For newer ircd's I've tested, @%#channel ignores everything in prefixes#channel except the lowest value status prefix, which makes it send out messages as if the target were %#channel, but the message is received by everyone at that status level plus everyone at a higher level. So, /notice +#channel would go to all ops and halfops too.

But I've used this at networks in the past where they would send out only to the targets listed, so +#channel would be seen only by voices, so all the @ops would voice themselves to make sure they could see the messages going to voices too.

If there's a prefix not listed in STATUSMSG= then you risk having the group notice seen by all, or seen by none, instead of going to the specific group.

One difference between sending mass notices like this vs using % $+ $chan is that the group notice is usually blocked from being used by someone who isn't at that level or higher, while there's no restriction against spamming a list of nicks.

Code
OP1 {
  var %i 1 , %target , %flag 0

  while ($nick($chan,%i,a,rv)) {
    if ($v1 == $me) { inc %i | continue }
    if (%flag) { echo $chan $+(-> @% $+ $chan) $1- | var %flag 0 }
    var %target $addtok(%target,$v1,44)
    if ($numtok(%target,44) == 5) {
      .privmsg $gettok(%target,1-5,44) 0,14 $1- 
      var %target
    }
    inc %i
  }
  while (%target != $null) {
    .privmsg $gettok(%target,1-5,44) 0,14 $1- 
    var %target $gettok(%target,6-,44)
  }
}

Joined: Nov 2021
Posts: 91
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 91
thanks for your reaction maroon ive tested the code and i get

0 test

when doing /op1 test
it doesnt seem to send message to chanops

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
That's what I get for adding a last second change to a script right before posting it. I was destroying the $v1 and flipping the value of %flag

Code
OP1 {
  var %i 1 , %target , %flag 1
  while ($nick($chan,%i,a,rv)) {
    var %v1 $v1
    if ($v1 == $me) { inc %i | continue }
    if (%flag) { echo $chan $+(-> @% $+ $chan) $1- | var %flag 0 }
    var %target $addtok(%target,%v1,44)
    if ($numtok(%target,44) == 5) {
      .privmsg $gettok(%target,1-5,44) 0,14 $1- 
      var %target
    }
    inc %i
  }
  while (%target != $null) {
    .privmsg $gettok(%target,1-5,44) 0,14 $1- 
    var %target $gettok(%target,6-,44)
  }
}

Joined: Nov 2021
Posts: 91
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 91
thanks for your reply Wimsi tried your version as well but it seems to freeze mirc and not send message to chanops

tried your version maroon and seems to work thanks for that

Last edited by Simo; 11/02/22 03:54 PM.
Joined: Nov 2021
Posts: 91
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 91
i had one last final request : to have a delay between the messages to prevent disconnect due to excess flood
thanks in advance

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
Same excuse as marron, inc %i needs to be inc %n


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Before I try to script such a thing, did my suggestion of checkboxing "own messages" in flood controls not work?

edit: and does your network not support the group notice like /notice @#channelname message
the group message would send everything at once without needing to repeat it

Last edited by maroon; 11/02/22 04:47 PM.
Joined: Nov 2021
Posts: 91
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 91
thanks wims that seems to work

i wanted to do that per script maroon and not use general throttle

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
And my other question about whether /notice @%#channelname works, which would avoid all this?

As for spreading out the notices, the way i'd think of offhand would be stashing the queue of messages into a @window or hashtable, then use a timer to spit them out. I suppose this would need to handle a situation where you're doing this in 2 channels across 2 networks at the same time?

Joined: Nov 2021
Posts: 91
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 91
ircd doesnt allow sending of notices to channel

or rather channel mode settings wont allow

Last edited by Simo; 11/02/22 05:28 PM.
Joined: Nov 2021
Posts: 91
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 91
anyway we can add a delay between the messages ?

perhaps @timer in combination with $calc ?

Last edited by Simo; 11/02/22 06:15 PM.
Joined: Nov 2021
Posts: 91
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 91
i found another issue with your code maroon when a user is both voiced and chanop he doesnt get messaged while we wanted to send messages to chanops regardless of anything else like voice and such

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
I've never seen a network that treated group messages to status members the same way it treated a simple notice or ctcp to the channel itself. i.e. the 1st might be blocked, but the 2nd one would not be, except possibly restricted to people who had sufficient status to be receivers of such a message

/notice #channel message
/notice @#channel message

I was trying to fix an obvious hole in what you were trying to do, and fell victim to an unstated requirement. Your original usage would not have allowed a founder or protected op to see the message without also having +o. Change the $nick() usage to the following instead:

$nick($chan,%i,&~oh)

If you have any other status levels, you'd need to either add those manually, or just tell everyone to give themselves +o also

Joined: Nov 2021
Posts: 91
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 91
thanks for the explanation and the solution maroon / wims much apreciated


Link Copied to Clipboard