Snippets Project Page
Author: maroon
Added: 1y
Updated: 1y
mIRC: v7.72
Hits: 373
Downloads: 9
Review: entropy
Size: 7.18KB
1 0
Login to vote.
Debugga
v1.01
Tested in v7.72, let me know if it doesn't work in v7.48 or later
enables having a single @debug window with all server connection messages in per-network color
can easily edit the alias to define different colors for all your networks
can also edit to change the style of output if having hex or $utfdecode display is useful
Download
JSON
▲ Review
▼ Source
/* { Debugga by maroon 2022-23 v1.01 Just run /debugga at each network whose in/out server traffic should be in @debug window Can change defaults: /debugga incolor subroutine_number ... where incolor is 0-98 and subroutine is any of 1 2 3, i.e. /debugga 13 or /debugga 13 2 Instead of having a separate @debug window for every server connection, has 1 window for all... This sets a different color for each network's inbound, but same red for everwhere's outbound It has 2 different color palettes depending on whether your background color is dark or light The colors and network names are just demo, so feel free to change them, or add additional elseif name/colors! If you make any changes (that includes changing colors) to the 'debugga' alias while the called subroutine is sending lines to the @debug window, you must either * re-connect to that server so the perform-on-connect can take effect * re-run /debugga on each server connection where the change needs to take effect * you can rerun debugga for all connections /scon -at1 debugga If you want to change which of the 3 subroutines is executed for each @debug line then you can edit the /debugga alias to point at the other alias subroutine and then execute /debugga for whichever server(s) you want to see the change * The main sub1 subroutine shows the messages as normal text * The alternate sub1 subroutine shows the messages as normal text decoded from utf8 encoding * The optional 2nd subroutine tries to show only the message portion as hex, and the prefix as text * The optional 3rd subroutine shows the ENTIRE server message as hex including any @tags * No need to re-run for edits to debuggasub1 to take effect * Note: even though the @debug window has a switchbar, entering "//ping $me" will not execute at all networks, but only the network where the window is first opened, as shown in the titlebar v1.01 just fixes incomplete docs, and als changes the ON CONNECT message to echo only to status window not $active too } */ alias debugga { ; z = shown at tail end of switchbar, bottom of treebar j3000=limit to 3000 rows !window -ze2Dj3000k @debug !titlebar @debug active= $+ $scid($window(@debug).cid).network logging: $addtok($gettok($window(@debug).titlebar,3-,32),$network,32) if ($istok(network1 network2,$network,32)) { echo -st debugga disabled at network $network | return } if ($1 isnum 0-98) var %incolor $int($1) elseif ($istok(1 88 91,$color(background),32)) { ; for list of dark backgrounds, a list of foreground colors that *should* contrast if ($network == Libera.Chat) var %incolor 56 , %fyi green elseif ($network == SwiftIRC) var %incolor 58 , %fyi dark cyan elseif ($network == EFNet) var %incolor 46 , %fyi lite cyan elseif ($network == UnderNet) var %incolor 54 , %fyi yellow elseif ($network == Twitch) var %incolor 62 , %fyi magenta elseif ($network == IRCgo) var %incolor 53 , %fyi orange else var %incolor 0 , %fyi caucasian } else { ; if not listed as a dark background, a list of foreground colors that *should* contrast against light background if ($network == Libera.Chat) var %incolor 32 , %fyi green elseif ($network == SwiftIRC) var %incolor 71 , %fyi bluegreen elseif ($network == EFNet) var %incolor 60 , %fyi blue elseif ($network == UnderNet) var %incolor 53 , %fyi orange elseif ($network == Twitch) var %incolor 62 , %fyi magenta elseif ($network == IRCgo) var %incolor 73 , %fyi purple else var %incolor 88 , %fyi african-american } if ($2 isnum 1-3) var %subroutine debuggasub $+ $int($2) else { var %subroutine debuggasub1 ; you can use this to make one of the networks use a different style of subroutine than the default ; if ($network == SwiftIRC) var %subroutine debuggasub2 ; if ($network == Libera.Chat) var %subroutine debuggasub2 } !echo -st per-network color debug info to @debug window now activated! $chr(22) event: $event $chr(22) network: $network $chr(22) server: $server $chr(22) servertarget: $servertarget $chr(22) $& self: $me $chr(22) uptime(system) $duration($uptime(system,3),3) $chr(22) uptime(mirc) $duration($uptime(mirc,3),3) $& $chr(22) uptime(server) $calc($uptime(server)/1000) $+ sec subroutine: %subroutine $& $chr(3) $+ %incolor incoming server messages on network $network are in this color %incolor !debug -pio52r $+ %incolor @debug %subroutine } alias debuggasub1 { !returnex $+([,$time,],[,$debuggascon,],[,$network,]) $parms } ; can use below alias instead, if you want to show the pseudo-milliseconds too... ; note that by default the @debug window shows the messages as utf8-encoded, ; so the alias below decodes them so that $chr(10004) is shown as the checkmark instead of as the 3 encoding characters! alias debuggasub1 { !returnex $+($fakestamp,[,$debuggascon,],[,$network,]) $utfdecode($parms) } ; used to show the Nth connection alias debuggascon { var %i 1 | while ($scon(%i).cid != $cid) inc %i | return %i } /* { This creates a timestamp from combining $ctime with the last 3 digits of $ticksqpc Note that this is NOT the same as millisecond, and the 1/1000'th of second value almost certainly rolls over without the second itself changing, so this is just to help see the gap between messages Also, the longer is your computer's uptime, the further these drift apart: //var -s %a $ticksqpc , %b $ticks , %c %a - %b ... and not the same directional drift for everyone } */ alias fakestamp { return $+([,$time($ctime),.,$right($ticksqpc,3),]) } ; hex excluding the @IrcV3tag and everything preceding the :string parameter ; sub2 hex only beginning with the 1st parm beginning with ':' ; (!) means no such parm, (~) means everything preceding that ":" is literal and following it is hex alias debuggasub2 { var %prefix $+([,$time,.,$right($ticksqpc,3),],[,$debuggascon,],[,$network,]) !if (<-* iswm $1) { ; returnex entire literal text if regex doesnt match stuff :stuff if (!$regex(foo,$parms ,/^(<- (?:@[^ ]+ |).*? :)(.+)/u)) returnex %prefix (!) $parms ; skip hex'ing prior to :parameter returnex %prefix $parms (~) $regsubex($regml(foo,2),/(.)/gu,$base($asc(\t),10,16,2) $+ $chr(32)) } !if (!$regex(foo,$parms ,/^(-> [^ ]+ (?:@[^ ]+ |).*? :)(.+)/u)) !returnex %prefix (!) $parms !returnex %prefix $parms (~) $regsubex($regml(foo,2),/(.)/gu,$base($asc(\t),10,16,2) $+ $chr(32)) } ; hex of everything including the IRCv3 @tag, defending against very long tag causing string longer than $maxlenl alias debuggasub3 { var %prefix $+([,$time,.,$right($ticksqpc,3),],[,$debuggascon,],[,$network,]) !noop $regsubex(foo,$parms,,,&parms) var %hex $regsubex($bvar(&parms,1- $+ $calc($maxlenl //4)),/([0-9]+)/g,$base(\1,10,16,2)) !returnex $left(%prefix $qt($parms) %hex,$maxlenl) } ; LOGON is to see SASL handshake, CONNECT re-executes in case LOGON didn't on *:LOGON:*:{ echo -s on logon network $network $qt($network) if ($network) debugga } on *:CONNECT:{ debugga }
Changelog:
0
0