mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2015
Posts: 6
M
Mouse Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: May 2015
Posts: 6
I wrote a tiny script to support CAP znc.in/self-message so that playback of query buffers displays the full conversation, not just messages from the remote party.

It prints messages to the appropriate query window, in the correct color, and with the correct timestamp (format).

ACTIONs are also formatted properly so they can be differentiated from normal messages.

It seems to work well with one caveat: I can't get mIRC to stop opening a blank query window to myself ($me) despite using halt.

Any ideas on how to correct the issue and feedback/suggestions on the code in general would be appreciated.

Code:
; mIRC znc.in/self-message CAP support script by Mouse
; http://forums.mirc.com/ubbthreads.php/topics/252752
; v0.2 2015-05-08

; If server offers znc.in/self-message capability then request it.
raw CAP:*LS*znc.in/self-message*:{ .raw CAP REQ :znc.in/self-message }

; Process all private messages delivered to $me for which $me is not the target/recipient AND
; when no window for $me exists.
on ^*:OPEN:?:{
  if ($target != $me) {
    ; Make sure we have a query window to print to.
    if (!$window($target)) { query $target }
    ; Print message with proper formatting after checking if it's an ACTION.
    if ($gettok($rawmsg,4,32) == : $+ $chr(1) $+ ACTION) {
      echo $color(own text) -bfmt $+ $msgstamp $target * $nick $1-
    }
    else { echo $color(own text) -bfmt $+ $msgstamp $target < $+ $nick $+ > $1- }
    ; Halt further processing.
    halt
  }
}

; Process all private messages delivered to $me for which $me is not the target/recipient AND
; when a window for $me exists.
on ^*:TEXT:*:?:{
  if ($target != $me) {
    ; Make sure we have a query window to print to.
    if (!$window($target)) { query $target }
    ; Print message with proper formatting after checking if it's an ACTION.
    if ($gettok($rawmsg,4,32) == : $+ $chr(1) $+ ACTION) {
      echo $color(own text) -bfmt $+ $msgstamp $target * $nick $1-
    }
    else { echo $color(own text) -bfmt $+ $msgstamp $target < $+ $nick $+ > $1- }
    ; Halt further processing.
    halt
  }
}


This was tested with mIRC v7.41 and ZNC 1.6.0

Last edited by Mouse; 08/05/15 11:09 PM. Reason: Updated script to handle ACTIONs
Joined: Jul 2006
Posts: 3,944
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,944
You must use the on open event with ^ + halt to prevent a query window from openeing


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: May 2015
Posts: 6
M
Mouse Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: May 2015
Posts: 6
Thanks for the tip. I updated the script to include both an 'on OPEN' and 'on TEXT' trigger. Since a user may already have a query window open to themselves (unusual but allowed) when a self-message arrives it seems there's no way to do it with just one of the two triggers and both are required.

Seems to be working perfectly so far. grin

Joined: Jul 2010
Posts: 8
W
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
W
Joined: Jul 2010
Posts: 8
Hey I logged in just to say thanks. This works perfectly. I just setup my own ZNC server a while ago and this really was the last thing to click into place. laugh

Joined: May 2015
Posts: 6
M
Mouse Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: May 2015
Posts: 6
Glad to hear this was useful to someone! smile

Since I'm no longer actively using mIRC I'll also add the following while I'm here...

Be advised that this script may stop functioning in the future if:
* ZNC deprecates znc.in/self-message in favor of IRCv3.2 echo-message
* CTCP is deprecated in favor of IRCv3.3 intents
* Capability handling in mIRC changes in a manner incompatible with this script

Joined: May 2018
Posts: 193
Vogon poet
Offline
Vogon poet
Joined: May 2018
Posts: 193
I modded this script to make my nick look orange like it's set in $me but, there is an automatic way to do that for every color set in $me or the color number always needs to be changed for $nick?

Code
; mIRC znc.in/self-message CAP support script by Mouse
; http://forums.mirc.com/ubbthreads.php/topics/252752
; v0.2 2015-05-08

; If server offers znc.in/self-message capability then request it.
raw CAP:*LS*znc.in/self-message*:{ .raw CAP REQ :znc.in/self-message }

; Process all private messages delivered to $me for which $me is not the target/recipient AND
; when no window for $me exists.
on ^*:OPEN:?:{
  if ($target != $me) {
    ; Make sure we have a query window to print to.
    if (!$window($target)) { query $target }
    ; Print message with proper formatting after checking if it's an ACTION.
    if ($gettok($rawmsg,4,32) == : $+ $chr(1) $+ ACTION) {
      echo $color(own text) -bfmt $+ $msgstamp $target * $nick $1-
    }
    else { echo $color(own text) -bfmt $+ $msgstamp $target < $+ $chr(3) $+ 7 $+ $nick $+ $chr(3) $+ > $1- }
    ; Halt further processing.
    halt
  }
}

; Process all private messages delivered to $me for which $me is not the target/recipient AND
; when a window for $me exists.
on ^*:TEXT:*:?:{
  if ($target != $me) {
    ; Make sure we have a query window to print to.
    if (!$window($target)) { query $target }
    ; Print message with proper formatting after checking if it's an ACTION.
    if ($gettok($rawmsg,4,32) == : $+ $chr(1) $+ ACTION) {
      echo $color(own text) -bfmt $+ $msgstamp $target * $nick $1-
    }
    else { echo $color(own text) -bfmt $+ $msgstamp $target < $+ $chr(3) $+ 7 $+ $nick $+ $chr(3) $+ > $1- }
    ; Halt further processing.
    halt
  }
}

Joined: Jan 2004
Posts: 1,835
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,835
Not clear what you mean by "set in $me".

If you refer to a 'rule' for $me in 'nick colors', you can get that color like

//echo -a $cnick($me).color or $cnick($me,1).color

which might not be the same as your color in the nicklist if /cline were used to override that

//echo -a $nick($chan,$me).color

If you don't mean this, please be more clear what you did to set the 'in $me'

Joined: May 2018
Posts: 193
Vogon poet
Offline
Vogon poet
Joined: May 2018
Posts: 193
Yes sorry I mean the $me from alt+b settings, it's set to orange 7 for messages (or nicklist).

Joined: May 2018
Posts: 193
Vogon poet
Offline
Vogon poet
Joined: May 2018
Posts: 193
This one works perfectly thank you maroon:

Code
; mIRC znc.in/self-message CAP support script by Mouse
; http://forums.mirc.com/ubbthreads.php/topics/252752
; v0.2 2015-05-08

; Mod with $nick color same as $me color.

; If server offers znc.in/self-message capability then request it.
raw CAP:*LS*znc.in/self-message*:{ .raw CAP REQ :znc.in/self-message }

; Process all private messages delivered to $me for which $me is not the target/recipient AND
; when no window for $me exists.
on ^*:OPEN:?:{
  if ($target != $me) {
    ; Make sure we have a query window to print to.
    if (!$window($target)) { query $target }
    ; Print message with proper formatting after checking if it's an ACTION.
    if ($gettok($rawmsg,4,32) == : $+ $chr(1) $+ ACTION) {
      echo $color(own text) -bfmt $+ $msgstamp $target * $nick $1-
    }
    else { echo $color(own text) -bfmt $+ $msgstamp $target < $+ $chr(3) $+ $cnick($me).color $+ $nick $+ $chr(3) $+ > $1- }
    ; Halt further processing.
    halt
  }
}

; Process all private messages delivered to $me for which $me is not the target/recipient AND
; when a window for $me exists.
on ^*:TEXT:*:?:{
  if ($target != $me) {
    ; Make sure we have a query window to print to.
    if (!$window($target)) { query $target }
    ; Print message with proper formatting after checking if it's an ACTION.
    if ($gettok($rawmsg,4,32) == : $+ $chr(1) $+ ACTION) {
      echo $color(own text) -bfmt $+ $msgstamp $target * $nick $1-
    }
    else { echo $color(own text) -bfmt $+ $msgstamp $target < $+ $chr(3) $+ $cnick($me).color $+ $nick $+ $chr(3) $+ > $1- }
    ; Halt further processing.
    halt
  }
}

Joined: May 2015
Posts: 6
M
Mouse Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: May 2015
Posts: 6
As mentioned above it's not entirely clear what you mean by colors "set in $me" however if you're referring to a Nick Colors rule for $me then the updated script below should work. I've also fixed a bug in the script so that it properly applies mIRC's coloring rules when it comes to own actions: the "own text" color overrides the "action text" color only when "own text" is not the same color as "normal text".

Note that when it comes to coloring your nickname it may not be 100% accurate as you can apply other match requirements to a color nick entry beyond simply the nickname and here we're not checking anything beyond whether an entry for $me exists and what its color is, however for the purposes of this script it should be good enough or if not you may edit the owncolor alias to be more stringent.

Code
; mIRC znc.in/self-message CAP support script by Mouse
; http://forums.mirc.com/ubbthreads.php/topics/252752
; v0.3 2021-06-02

; If server offers znc.in/self-message capability then request it.
raw CAP:*LS*znc.in/self-message*:{ .raw CAP REQ :znc.in/self-message }

; Local alias to get correct "own" action and nick colors
alias -l owncolor {
  if ($1 == action) {
    if ($color(own text) == $color(normal text)) { return $color(action text) }
    else { return $color(own text) }
  }
  if ($1 == nick && $cnick($me) > 0) {
    return $cnick($me).color
  }
}

; Process all private messages delivered to $me for which $me is not the target/recipient AND
; when no window for $me exists.
on ^*:OPEN:?:{
  if ($target != $me) {
    ; Make sure we have a query window to print to.
    if (!$window($target)) { query $target }
    ; Print message with proper formatting after checking if it's an ACTION.
    if ($gettok($rawmsg,4,32) == : $+ $chr(1) $+ ACTION) {
      echo $owncolor(action) -bfmt $+ $msgstamp $target * $nick $1-
    }
    else { echo $color(own text) -bfmt $+ $msgstamp $target < $+ $chr(3) $+ $owncolor(nick) $+ $nick $+ $chr(3) $+ > $1- }
    ; Halt further processing.
    halt
  }
}

; Process all private messages delivered to $me for which $me is not the target/recipient AND
; when a window for $me exists.
on ^*:TEXT:*:?:{
  echo -a result $owncolor(action)
  if ($target != $me) {
    ; Make sure we have a query window to print to.
    if (!$window($target)) { query $target }
    ; Print message with proper formatting after checking if it's an ACTION.
    if ($gettok($rawmsg,4,32) == : $+ $chr(1) $+ ACTION) {
      echo $owncolor(action) -bfmt $+ $msgstamp $target * $nick $1-
    }
    else { echo $color(own text) -bfmt $+ $msgstamp $target < $+ $chr(3) $+ $owncolor(nick) $+ $nick $+ $chr(3) $+ > $1- }
    ; Halt further processing.
    halt
  }
}


Tested on mIRC 7.65 and ZNC 1.8.2

Joined: May 2018
Posts: 193
Vogon poet
Offline
Vogon poet
Joined: May 2018
Posts: 193
Thank you Mouse for the mod, this one though prints two
Quote
result 6
result 6
in the channel, not sure why. Action and nick colors are perfect in queries other than that small issue.

Joined: Jan 2004
Posts: 1,835
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,835
The script has a debugging line in it, which causes those echoes:

echo -a result $owncolor(action)

The result goes into whichever is your active window, which in your case happened to be the channel. It could have been the actual query window, a different query window, the status window, or even could be at a different network.

Joined: May 2015
Posts: 6
M
Mouse Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: May 2015
Posts: 6
I just missed a debugging line in the code as the person above mentioned. I can't go back and edit that post so I'll post the corrected code below so other people can copy/paste:

Code
; mIRC znc.in/self-message CAP support script by Mouse
; http://forums.mirc.com/ubbthreads.php/topics/252752
; v0.4 2021-06-04

; If server offers znc.in/self-message capability then request it.
raw CAP:*LS*znc.in/self-message*:{ .raw CAP REQ :znc.in/self-message }

; Local alias to get correct "own" action and nick colors
alias -l owncolor {
  if ($1 == action) {
    if ($color(own text) == $color(normal text)) { return $color(action text) }
    else { return $color(own text) }
  }
  if ($1 == nick && $cnick($me) > 0) {
    return $cnick($me).color
  }
}

; Process all private messages delivered to $me for which $me is not the target/recipient AND
; when no window for $me exists.
on ^*:OPEN:?:{
  if ($target != $me) {
    ; Make sure we have a query window to print to.
    if (!$window($target)) { query $target }
    ; Print message with proper formatting after checking if it's an ACTION.
    if ($gettok($rawmsg,4,32) == : $+ $chr(1) $+ ACTION) {
      echo $owncolor(action) -bfmt $+ $msgstamp $target * $nick $1-
    }
    else { echo $color(own text) -bfmt $+ $msgstamp $target < $+ $chr(3) $+ $owncolor(nick) $+ $nick $+ $chr(3) $+ > $1- }
    ; Halt further processing.
    halt
  }
}

; Process all private messages delivered to $me for which $me is not the target/recipient AND
; when a window for $me exists.
on ^*:TEXT:*:?:{
  if ($target != $me) {
    ; Make sure we have a query window to print to.
    if (!$window($target)) { query $target }
    ; Print message with proper formatting after checking if it's an ACTION.
    if ($gettok($rawmsg,4,32) == : $+ $chr(1) $+ ACTION) {
      echo $owncolor(action) -bfmt $+ $msgstamp $target * $nick $1-
    }
    else { echo $color(own text) -bfmt $+ $msgstamp $target < $+ $chr(3) $+ $owncolor(nick) $+ $nick $+ $chr(3) $+ > $1- }
    ; Halt further processing.
    halt
  }
}

Joined: May 2018
Posts: 193
Vogon poet
Offline
Vogon poet
Joined: May 2018
Posts: 193
Hi Mouse, the latest few releases and betas of mIRC changed "some stuff" for how the ZNC interacts with the client, is this code still good?
I noticed that my nick wasn't present on some queries today but I can't reproduce it now.

Thanks.

Joined: May 2015
Posts: 6
M
Mouse Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: May 2015
Posts: 6
Testing with mIRC 7.69, ZNC 1.8.2, and the most recent version of the code I posted I'm not seeing any issues. Messages sent while there are multiple clients attached as well as during buffer playback appear to be handled properly. I can't think of a reason why a nick would not be present for a message. If you can come up with a way to reproduce the issue let me know.

I'll make an effort to keep the script valid and working for the znc.in/self-message capability for stable releases if someone informs me there's an issue. I won't be testing with the beta version. I know Khaled has been making changes to how mIRC implements the IRCv3 echo-message capability in the beta and maybe there's a potential that my code won't work properly with the next stable release. If that happens update this thread with the details and I'll take a look.


Link Copied to Clipboard