|
Joined: Feb 2015
Posts: 17
Pikka bird
|
OP
Pikka bird
Joined: Feb 2015
Posts: 17 |
I was pleasantly surprised by this code, that pings every IRC network server you're connected to: on *:START:.timerAnti10053 -o 0 60 scon -at1 raw -q ping Anti10053 I'd like to have a script that creates separate debug windows named with particular IRC Network name for every IRC Network that I'm Connected, Disconnected, or Connecting to. Maybe scon -a could be used? How should the code look like? I need such script (debug windows) to troubleshoot mIRC errors like [10101] Host disconnected, [10053] Software caused connection abort and for general monitoring of my primitive script behavior. Thank you.
|
|
|
|
Joined: Jul 2006
Posts: 4,185
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,185 |
What do you mean with debug window, do you mean /debug? If you want to troubleshoot mIRC errors like you mentioned, you can simply use on disconnect
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Feb 2015
Posts: 17
Pikka bird
|
OP
Pikka bird
Joined: Feb 2015
Posts: 17 |
Yes, I'm talking about Debug window /debug -pt @NetworkName
I'd like to have a script that creates separate debug windows /debug -pt @NetworkName named with particular IRC Network name for every IRC Network that I'm Connected, Disconnected, or Connecting to.
I want to have this not only for troubleshooting, but also to see what's happening under the hood, what input-output is going on between mIRC and Network server.
I don't know how the script should look like.
|
|
|
|
Joined: Jul 2006
Posts: 4,185
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,185 |
You cannot automatically attach a debug window to any status window as there is no event when you create a status window. This is going to be your main problem, you can use /scon -a but when? You only need to call /debug once per status window (regardless of their state, connected, disconnect or connecting to) so basically, the only solution is to create your own 'on newstatus' event, with a timer on *:start:hmake newstatuswindow | .timernewstatuswindow -m 0 80 aretherenewstatuswindow?
alias aretherenewstatuswindow? {
if ($isid) {
echo -a new status window created with cid $1
hadd -m newstatuswindow $1
; eventually adds here "/debug -pt @debug. $+ $1" to create a debug window
}
else scon -a if (!$hget(newstatuswindow,$cid)) noop $!aretherenewstatuswindow?($cid)
}
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Jan 2004
Posts: 1,361
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,361 |
The logon event could be used but I think he was just wanted an alias to trigger manually.
|
|
|
|
Joined: Jul 2006
Posts: 4,185
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,185 |
Yeah, but on logon would never trigger for status window you never connect with
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Jan 2004
Posts: 1,361
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,361 |
Well there's nothing to debug if you never connect
|
|
|
|
Joined: Jul 2006
Posts: 4,185
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,185 |
Lol, I almost wanted to mention that, but he said he wanted 'disconnected' status windows, which is both the ones you previously connected to but also the ones you never connected to, I can see how one would want to do it once and for all. Here is an edit of the code anyway: on *:start:hmake newstatuswindow | .timernewstatuswindow -m 0 80 aretherenewstatuswindow?
alias aretherenewstatuswindow? {
if ($isid) {
echo -a new status window created with cid $1
hadd -m newstatuswindow $1 1
; eventually adds here "/debug -pt @debug. $+ $1" to create a debug window
}
else scon -a if (!$hget(newstatuswindow,$cid)) noop $!aretherenewstatuswindow?($cid)
}
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Feb 2015
Posts: 17
Pikka bird
|
OP
Pikka bird
Joined: Feb 2015
Posts: 17 |
Thank you for your input, Wims and Loki12583. Wims script above works just fine. It creates debug windows for all of my networks that I connect to on mIRC startup. The script also creates debug windows even when I'm manually sending /server -n command afterwards. Nice. It's interesting to mention, that on mIRC startup debug -pt @debug. $+ $1 part of the script creates a first debug window for my first network that I'm connecting to, named @debug.1. However other debug windows for all other networks from my autoconnect list are named like @debug.20, @debug.44 etc. However, I'm only autoconnecting to 15 networks. Creation of a new status window using /server -n command resulted in creation of debug window named @debug.1593. I wonder how that numbers originate? Is it possible to name created debug windows to something like @debug.NetworkName ? I've tried using debug -pt @debug. $+ $network, but it didn't work. $network wasn't capturing Network name. By the way, the reason for wanting debug windows to be created for all status windows: connected, disconnected - came from my erroneous perception that on case of lost connection and re-connection debug window would stop capturing data, which was wrong, because as you've explained debug window is created for particular status window and has nothing to do with connection state. My typical usage scenario is that on mIRC startup, mIRC automatically connect to 15 networks. I want script to create debug windows for all of those networks. Therefore, ON *:LOGON: could probably be used. I've tried using this code, but it didn't work: ON *:LOGON:debug -pt @debug. $+ $network Wims script already works just fine, however I wonder how code should look like if we would be using ON *:LOGON: ?
|
|
|
|
Joined: Jul 2006
Posts: 4,185
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,185 |
On logon takes a parameter, and you should use the ^ version of the event, which is triggered before mIRC sends stuff, check /help on logon on ^*:LOGON:*:debug -pt @debug. $+ $network I used $cid because $cid is guaranteed to be unique, mIRC has a function internally that keep increasing a variable by 1, just to make sure it's a unique value. Not all call to that function are visible to us, it's mostly called to makes sure unique value are used internally, that's why it jumps from 1 to 44 to 72, because in the meantime the function has been called a lot. $network is not guaranteed to be an unique value, that value is taken from the server when you connect, the server could technically put anything here. If you want to assume this is not going to be a problem (and well, it shouldn't be), use $network For reference: how $cid value are generated
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Feb 2015
Posts: 17
Pikka bird
|
OP
Pikka bird
Joined: Feb 2015
Posts: 17 |
Wims, your script that creates a debug window for every status window is more comfortable to use than on ^*:LOGON:*:debug -pt @debug. $+ $network approach, because on ^*:LOGON:* is triggered on every reconnect cycle (and there may be many of those cycles as time goes by), therefore it's crucial for ^*:LOGON:*:debug -pt @debug. $+ $network to create a debug window with exactly the same name over and over again, because otherwise debug windows with different names would start to accumulate.
$network isn't reliable, because on mIRC startup when I connect to my 15 IRC networks, $network only captures network names for half of the networks (probably because connection to all of those networks takes place at the same time and it's too fast to capture the network name for every network), so in the end some of debug windows are named like @debug.EFNet (preferred name), but for many other networks debug output goes to @debug. (if network name wasn't captured). On case of disconnect-reconnect, if network name was captured, than the output is changed from @debug. to @debug.networkname.
Using $cid or something like var %counter = 0, inc %counter with on ^*:LOGON:* would result in accumulation of even greater number of debug windows over time due to reconnect cycles, therefore I've decided to stick with your first script, Wims.
Talking about your first script, is it possible to use a different naming pattern for debug windows instead of $cid, using something like var %counter = 0, inc %counter, so debug windows would be named as @debug1, @debug2 etc. instead of random values that $cid generates ?
|
|
|
|
Joined: Jul 2006
Posts: 4,185
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,185 |
Calling /debug again with the same window name wouldn't be a problem in itself, however I totally overlooked the fact that $network isn't filled at the time the on logon event trigger, so yeah, can't use $network there, but can't use $network with my method either. so in the end some of debug windows are named like @debug.EFNet (preferred name), but for many other networks debug output goes to @debug. I think that's just a side effect, sometimes $network will be taken from your server's configuration, like the group name (alt + o > connect > server) or something, so it's possible $network has a value at on logon time, but it's not reliable anyway. Yeah it's possible to use a different naming scheme, we have $cid, which represent a Connectioin ID, people often request $con in the past, the connection number (related to /scid and /scon). $con can be scripted very easily: alias con {
var %a 1
while ($scon(%a)) {
if ($v1 == $cid) return %a
inc %a
} However, when you close a status window, the debug window isn't closed automatically, $cid value doesn't change if you close a status window, but $con will, so that's not a good idea. For example, you have 3 status windows, A B C, with their 3 associated debug windows @1 @2 @3, if you close the status window B, suppose @2 is closed accordingly, you now have A B with @1 @3, but should be @1 @2... That being said, if you close a status window, you'll have to recreate the event the same way: you must know when a status window is closed, if you know that, you COULD in theory copy the current content of each windows, close all windows, and recreate them with a correct name. With that in mind, tell me if you would like that, and the script can be improved to also make an event for the closing of status window, handling the copy of the current content of debug windows etc.. Edit: using your own counter has the same issue.
Last edited by Wims; 14/08/15 09:15 AM.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Feb 2015
Posts: 17
Pikka bird
|
OP
Pikka bird
Joined: Feb 2015
Posts: 17 |
For example, you have 3 status windows, A B C, with their 3 associated debug windows @1 @2 @3, if you close the status window B, suppose @2 is closed accordingly, you now have A B with @1 @3, but should be @1 @2... Yes, you're right. However, using such primitive counters only causes problems when status windows are closed. In my typical scenario, a stable list of networks is opened on mIRC startup and non of status windows gets closed. In such usage scenario, something like var %counter = 0, inc %counter should probably work just fine. With that in mind, tell me if you would like that, and the script can be improved to also make an event for the closing of status window, handling the copy of the current content of debug windows etc.. That would be a very sophisticated code, Wims. If that's not too much to ask, it would be great to have such a smart script. However, if it's too much of a hassle, simply incorporating a primitive window counter into your script would be enough for my current needs.
|
|
|
|
Joined: Jul 2006
Posts: 4,185
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,185 |
I'll see. In any case, if you want to assume such a scenario, you can use $con then
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Feb 2015
Posts: 17
Pikka bird
|
OP
Pikka bird
Joined: Feb 2015
Posts: 17 |
Yes, I've tried incorporating $con into your script unsuccessfully, it broke the code.
I don't know which instances of cid in your script should be replaced with $con.
|
|
|
|
Joined: Jul 2006
Posts: 4,185
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,185 |
None =) You must keep $cid so the code works, you only use $con when creating the window, that is when calling /debug, replace $1 (which is $cid) with $con there
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Feb 2015
Posts: 17
Pikka bird
|
OP
Pikka bird
Joined: Feb 2015
Posts: 17 |
The code below didn't work: on *:start:hmake newstatuswindow | .timernewstatuswindow -m 0 80 aretherenewstatuswindow?
alias con {
var %a 1
while ($scon(%a)) {
if ($v1 == $cid) return %a
inc %a
}
alias aretherenewstatuswindow? {
if ($isid) {
echo -a new status window created with cid $1
hadd -m newstatuswindow $1 1
debug -pt @debug. $+ $con
}
else scon -a if (!$hget(newstatuswindow,$cid)) noop $!aretherenewstatuswindow?($cid)
}
The code below works: on *:start:hmake newstatuswindow | .timernewstatuswindow -m 0 80 aretherenewstatuswindow?
alias aretherenewstatuswindow? {
if ($isid) {
echo -a new status window created with cid $1
hadd -m newstatuswindow $1 1
debug -pt @debug. $+ $con
}
else scon -a if (!$hget(newstatuswindow,$cid)) noop $!aretherenewstatuswindow?($cid)
}
alias con {
var %a 1
while ($scon(%a)) {
if ($v1 == $cid) return %a
inc %a
}
Is it ok to remove this line from the script? The script seems to work without this line: echo -a new status window created with cid $1 By the way, I still don't understand how this part of your code actually detects if a new status window was detected, but it obviously detects every new status window: on *:start:hmake newstatuswindow | .timernewstatuswindow -m 0 80 aretherenewstatuswindow?
alias aretherenewstatuswindow? {
if ($isid) {
hadd -m newstatuswindow $1 1
}
else scon -a if (!$hget(newstatuswindow,$cid)) noop $!aretherenewstatuswindow?($cid)
|
|
|
|
|