mIRC Home    About    Download    Register    News    Help

Print Thread
#271522 09/04/23 02:38 AM
Joined: Mar 2021
Posts: 48
R
Robert Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Mar 2021
Posts: 48
Can someone fixed or rewrite this my code to work pls?
Here is my code:
Code
on *:op:#: {
  if ($istok(#freeirc #Official #test1,$chan,32)) {
    if ($nick == X) || ($nick == *.undernet.org) { return }
    if ($nick == $me) { Notice }
  }
}
alias Notice {
  whois $nick
}
raw 311:*: {
  if (*users.undernet.org iswm $4) && ($nick == $7) { /onotice $chan - $+ @ $+ $chan $+ - $nick ( $+ $7 $+ ) deopped: $opnick | /notice $opnick You're deopped by $nick ( $+ $7 $+ ) on $chan  | return }
  else { /onotice $chan - $+ @ $+ $chan $+ - $nick ( $+ $nick $+ ) opped: $opnick | /notice $opnick You're opped by $nick ( $+ $nick $+ ) on $chan  }
}

I want that code do this:
1. When some one/me/X/*.undernet.org Op anyone in #freeirc #Official, if:
+ X or *.undernet.org sets mode +o everyone then bot do nothing (return)
+ Me or every Nickname do sets mode +o in channels, then my bot notice to all Ops in that chan.
But:
Example: if mynick is Kenny and my address is ~Kenny@123.123.123.123, when i login to X then my host is ~Kenny@Kenny.users.undernet.org
Now i change my nick to Robert (my host still ~Kenny@Kenny.users.undernet.org), but when Robert sets mode +o, i want my bot will notice like this:
@Ops -@$chan- Robert (Kenny) opped: $opnick | notice $opnick You're opped by Robert (Kenny) on $chan

Thank you for help

This is my rawlog on raw 311:
<- 04/09/23 09:28:45 - :dallas.tx.us.undernet.org 311 Robert Robert ~Kenny Kenny.users.undernet.org * :Kenny
<- 04/09/23 09:28:45 - :dallas.tx.us.undernet.org 319 Robert Robert :#undernet @#test1 @#freeirc @#userbot @#diaspora @#irccloud
<- 04/09/23 09:28:45 - :dallas.tx.us.undernet.org 312 Robert Robert dallas.tx.us.undernet.org :Psychz Undernet Server
<- 04/09/23 09:28:45 - :dallas.tx.us.undernet.org 330 Robert Robert Kenny :is logged in as
<- 04/09/23 09:28:45 - :dallas.tx.us.undernet.org 338 Robert Robert ~Kenny@113.23.49.3 113.23.49.3 :Actual user@host, Actual IP
<- 04/09/23 09:28:45 - :dallas.tx.us.undernet.org 317 Robert Robert 32477 1680343544 :seconds idle, signon time
<- 04/09/23 09:28:45 - :dallas.tx.us.undernet.org 318 Robert Robert :End of /WHOIS list.

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
This just needs a few extra lines, which I've inserted into your ON OP event. I added a little extra code just to make it easier to understand, and you can replace the %fulladdress.opped and %fulladdress.opper with the identifier calls that create them. This is also assuming you've already enabled /IAL ON so that it has the address of the person being opped. This is also echoing the messages to the channel instead of actually making them, so you can see what the message will be prior to putting it into production.

Code
on *:op:#: {
  if ($istok(#freeirc #Official #test1,$chan,32)) {
    if ($nick == X) || ($nick == *.undernet.org) { return }
    if ($nick == $me) { Notice }

  var %acct.opped , %acct.opper , %fulladdress.opped $ial($opnick) , %fulladdress.opper $fulladdress
  if (*.users.undernet.org iswm %fulladdress.opped) var %acct.opped ( $+ $gettok($gettok(%fulladdress.opped,2,64),1,46) $+ )
  if (*.users.undernet.org iswm %fulladdress.opper) var %acct.opper ( $+ $gettok($gettok(%fulladdress.opper,2,64),1,46) $+ )
  echo -g $chan /onotice $chan $opnick %acct.opped opped by $nick
  echo -g $chan /notice $opnick You're opped by $nick %acct.opper on $chan

  }
}

Joined: Nov 2021
Posts: 81
Babel fish
Offline
Babel fish
Joined: Nov 2021
Posts: 81
i came up with this with a delay for the messages:

Code

on *:op:#: {
  if ($istok(#freeirc #Official #test1,$chan,32)) {
    if ($nick != X) && ($nick != *.undernet.org) { 
      OPS $chan $nick $opnick
     .NOTICE $opnick You are opped by $nick on $chan
    }
  }
}


alias OPS {
  var %i 1 , %target , %flag 1
  while ($nick($1,%i,o)) {
    var %v1 $v1
    if ($regex($v1,/^(X| $+ $me $+ )$/i)) { inc %i | continue }
    if (%flag) { echo $1 $+(-> @% $+ $chan) $1- | var %flag 0 }
    var %target $addtok(%target,%v1,44) 
    if ($numtok(%target,44) == 5) {
      .timer $+ %i 1 $calc(%i - 5)  .NOTICE $gettok(%target,1-5,44) -@ops- $3 is opped by $2
      var %target
    }
    inc %i
  }
  while (%target != $null) {
    .timer $+ %i 1 $calc(%i  - 5)  .NOTICE $gettok(%target,1-5,44)  -@ops- $3 is opped by $2 
    var %target $gettok(%target,6-,44)
  }
}



Last edited by Simo; 09/04/23 08:00 PM.
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
yes, it's a shame that undernet doesn't support the /notice @#channel message format. A few observations on your code.

* in a small channel with fewer than 5-ish people, the final timer with $calc(%i - 5) can produce a negatve
* you have timers hardcoded as specific numbers for no reason. mirc likes to auto-assign timers to the lowest available integer, so this can easily trample an existing timer
* if numtok<=5, you don't need $gettok(%target,1-5,44), can just use %target
* Regex is powerful, but using regex in this way can end up with your mileage varying significantly. for normal nicks, but doesn't work well when $me is something like \dev\nul or maroon|away or [maroon]. In this case, it would've been much simpler and faster to use $istok(X $me,$v1,32)
* I haven't tested sufficiently, but I'm wondering if it's sufficient to check the "own messages" setting in flood controls, rather than adding timers to space these out at 5 seconds intervals?

Joined: Mar 2021
Posts: 48
R
Robert Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Mar 2021
Posts: 48
Thanks maroon and Simo for help and reply me soon! I do it by myself done

By the way, i have a question please:

How to notice to all voices in channel? which command?

Thanks all so much

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Well, first of all I made an assumption that turns out to be incorrect. I had tested a group message to all voices
/notice +#channelname message
and it didn't work, so I assumed that it didn't work for group "/notice @#channelname message" to all @Ops either, but that does. However, the /version reply in the status window contains STATUSMSG=@+ which means they're *both* supposed to work.

In fact, due to the Undernet 005 message containing STATUSMSG=@+, when you use /onotice $chan, mIRC sends 1 message to @ $+ $chan instead of otherwise sending potentially multiple outbound notices to target each op individually. So in my earlier code where it used
//onotice $chan message
at Undernet or at any network which contans STATUSMSG= containing @, mIRC does the equivalent of
//notice @ $+ $chan message
... and it works.

But until Undernet either fixes this bug or tells what alternate command I'm supposed to be using, I'm afraid a group notice to voices might need to be done similar to the way Simo described for @ops, except changing $nick($1,%i,o) to $nick($1,%i,v), and determining what is the ACTUAL limit for how many nicks can be targeted in each copy of the notice.

Perhaps Simo can explain how they knew to use 5 as the max targets at Undernet? Normally the /version reply contains TARGMAX= that tells the limit for how many nicks can be combined into a single message like
/notice nick1,nick2,nick3,nick4,nick5 message
... and I'm at some networks where 4 is the limit, and others where limit=1.

However at Undernet I used Simo's style of mass-target where I had a 2nd nick as the 12th target in the list, and it did receive the notice. So if there's a limit at Undernet, I don't yet know what it is.

While testing this, it would help you to have the @debug window open to see what mirc is actually sending outbound, and what is actually received. You can't test by manually having the same nick in the list multiple times, because mIRC trims it down to sending to them once.

Also be aware that the 510 limit for IRC messages also includes the list of nicks, so even if you're allowed to send 1 notice to 30 nicks at the same time, that this limits how long the message can be, the same way as would happen if you were messaging to a single nick of length 300-ish. But if the notice is 'too long' Undernet sends an error reply back to you instead of forwarding a notice that's chopped

Update.

Undernet said that /notice +#channel not working is a bug that I should report as an Issue, though they weren't sure whether it would be fixed by removing + from STATUSMSG= or by fixing STATUSMSG=

They also said that 20 is the limit for how many nicks you can stack together in a comma-delimited target list, so if you will never have that many voices, you can just build a long list like:

//var -s %chan $chan(1) | echo -ag /notice %chan $left($regsubex($str(x,$nick(%chan,0,v)),/x/g,$nick(%chan,\n,v) $+ $chr(44)),-1) message

Apparently there's also a separate limit for how many targets you can message within a specific time period, and you'll probably need to find those out yourself, as even if you're sending out a valid /notice to 2 voices, it could violate the cumulative limit.

Also, I reported that STATUSMSG= is supposed to also allow group targets for other things besides /notice including /msg /describe /ctcp etc, but those aren't even working for the @#channel target that works for /notice

Last edited by maroon; 10/04/23 06:24 AM.
Joined: Nov 2021
Posts: 81
Babel fish
Offline
Babel fish
Joined: Nov 2021
Posts: 81
Thanks for pointing out the various issues to consider maroon

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Additional info for Robert. For Undernet only, you won't need to stack multiple nicks into the message to all-ops or all-voices, you can instead do:

To all ops:

/notice @#channel message
or
/quote WALLCHOPS #channel message to all ops

To all voices:
/quote WALLVOICES #channel message to all voices

Note that if you use /WALLVOICES without the /quote preceding it, that mIRC is instead sending out /notice +#channel message, because that's what the /version token for STATUSMSG=@+ is promising will work but actually does not work. Also, even though +#channel is supposed to also be visible to everyone having a higher status, at Undernet the WALLVOICES messages cannot be seen by the @ ops unless they give themselves +v too.


Link Copied to Clipboard