mIRC Home    About    Download    Register    News    Help

Topic Options
#252752 - 08/05/15 07:35 PM ZNC Query Buffer Self-Message Support
Mouse Offline
Self-satisified door

Registered: 08/05/15
Posts: 3
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


Edited by Mouse (09/05/15 12:09 AM)
Edit Reason: Updated script to handle ACTIONs

Top
#252753 - 08/05/15 08:13 PM Re: ZNC Query Buffer Self-Message Support [Re: Mouse]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3435
Loc: France
You must use the on open event with ^ + halt to prevent a query window from openeing
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#252754 - 08/05/15 11:02 PM Re: ZNC Query Buffer Self-Message Support [Re: Wims]
Mouse Offline
Self-satisified door

Registered: 08/05/15
Posts: 3
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

Top
#258835 - 03/09/16 12:58 AM Re: ZNC Query Buffer Self-Message Support [Re: Mouse]
webhead Offline
Nutrimatic drinks dispenser

Registered: 22/07/10
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

Top
#258843 - 03/09/16 09:31 PM Re: ZNC Query Buffer Self-Message Support [Re: webhead]
Mouse Offline
Self-satisified door

Registered: 08/05/15
Posts: 3
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

Top