mIRC Home    About    Download    Register    News    Help

Print Thread
#233569 24/08/11 11:03 PM
Joined: Apr 2010
Posts: 969
F
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
$MyIdle - returns the number of seconds since something/anything was SENT TO the currently active connection. Be it a manual command or scripted, including PING/PONG events
If not connected to a server $null is returned.


I am SReject
My Stuff
FroggieDaFrog #233571 25/08/11 05:03 AM
Joined: Aug 2006
Posts: 183
T
Vogon poet
Offline
Vogon poet
T
Joined: Aug 2006
Posts: 183
Decently easy to script, but yeah, I've wanted this feature a number of times myself. I second this idea.


Yar
FroggieDaFrog #233584 26/08/11 12:40 AM
Joined: Apr 2010
Posts: 969
F
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
Just to add a note or two to this request:

It doesn't have to be sync'ed with what the server has as my idle time. I just want an identifer that returns the number of seconds since mIRC tried to send something to the server

I know in my first post I mentioned "PING/PONG" events, but what I meant was including the last time mIRC tried to send a PING request to the server or reply to a PING request with /PONG


I am SReject
My Stuff
FroggieDaFrog #233589 26/08/11 06:52 PM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Then you just want $idle, since that's what it does.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
argv0 #233594 26/08/11 08:35 PM
Joined: Dec 2002
Posts: 344
D
Pan-dimensional mouse
Offline
Pan-dimensional mouse
D
Joined: Dec 2002
Posts: 344
Originally Posted By: argv0
Then you just want $idle, since that's what it does.


$idle tells you the time since you last pressed enter in an edit box. It has nothing to do with data transmission.

Basically FroggieDaFrog is asking for the equivalent of $sock().ls and $sock().lr, except for server connections.

drum #233597 27/08/11 02:11 AM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Most of the time it's close enough, given that most /commands are related to server data. For who commonly perform local scripting tasks (/echo), it might be a bit off, but for the average user it should be spot on.

In any case, this can be scripted if you really need it with the following:

Code:
alias setidle { if (-> * iswm $1-) set %lastmsg. $+ $cid $ctime | return $1- }
alias myidle { return $calc($ctime - $($+(%,lastmsg.,$cid),2)) }
ON *:CONNECT:.debug -i nul setidle





- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
argv0 #233621 29/08/11 01:29 AM
Joined: Apr 2010
Posts: 969
F
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
I'm trying to avoid the /debug work around(It's what I'm currently using at the moment) because, for most users it's spot on. But for those same "local scripting tasks", /debug is quite commonly used as well to get raw numerics and the such.


I am SReject
My Stuff
FroggieDaFrog #233625 29/08/11 03:31 AM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
You could always overload your /debug and generalize it, for instance:

Code:
alias debug { 
  if (-i nul debug_multiplex != $1-) {
    echo $color(info) -sl * /debug: do not use this command, handle the DEBUG signal event instead.
  }
  !debug $1-
}
alias debug_multiplex { .signal -n DEBUG $1- | return $1- }
ON *:CONNECT:.debug -i nul debug_multiplex

; Uncomment this for the standard /debug @debug behaviour.
;ON *:SIGNAL:DEBUG:window @debug | echo @debug $1-


Instead of the error, you could also intelligently wrap the new command within the SIGNAL events, allowing you to handle multiple /debug commands at a time. It wouldn't be very hard. You'd add the file/window argument to a list of outputs and just loop through those outputs in your signal event:

Code:
; inside /debug alias:
var %opts = ""
if (-* iswm $1) { %opts = $1 | tokenize 32 $2- }
if ($1 == off) {
  %debug_outputs = $remtok(%debug_outputs,$2,0,32)
}
else {
  if (i isin %opts) { echo $color(info) -sl * /debug: handle the DEBUG signal event instead. | return }
  var %output = $iif($1 == on,debug.log,$1)
  if (@* iswm %output) window $iif(n isin %opts,-n,) %output
  %debug_outputs = $addtok(%debug_outputs,%output,32)
}

; add a default signal event
on *:SIGNAL:DEBUG: {
  var %i = 1
  while ($gettok(%debug_outputs,%i,32)) {
    var %output = $v1
    $iif(@* iswm %output,echo,write) %output $1-
    inc %i
  }
}


This doesn't handle some of the optional debug switches, but it should be clear how to add support for those, and not very difficult. I show the error message if -i is used, suggesting that they use the signal event instead of a custom alias. Wouldn't be that hard to support the identifier argument too, though.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
argv0 #233626 29/08/11 05:49 AM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
FYI, full debug multiplexer is here:

Code:
; DEBUG multiplexer
;
; Changes to normal /debug behaviour:
;
; 1. Initiating a new /debug does not end the previous debug command.
;    Messages will still be sent to the old window or file.
; 2. To stop a debug logger, type /debug off <window | filename>
;    Use /debug -i off <window | filename> <identifier> to stop a prior /debug -i call.
; 3. You can use ON *:SIGNAL:DEBUG: { ... } to watch for a debugging message.
alias debug {
  if ($1- == -i nul debug_multiplex) { .debug $1- | return }
  var %opts = ""
  if (-* iswm $1) { %opts = $1 | tokenize 32 $2- }
  if ($1 == off) {
    set %debug_outputs. $+ $cid $remtok(%debug_outputs. [ $+ [ $cid ] ],$iif($2,$2,debug.log),0,32)
    if (i isin %opts) {
      set %debug_identifiers. $+ $cid $remtok(%debug_identifiers. [ $+ [ $cid ] ],$3,0,32)
    }
  }
  else {
    var %output = $iif($1 == on,debug.log,$1)
    if (@* iswm %output) window $iif(n isin %opts,-n,) %output
    set %debug_outputs. $+ $cid $addtok(%debug_outputs. [ $+ [ $cid ] ],%output,32)
    if (i isin %opts) { 
      set %debug_identifiers. $+ $cid $addtok(%debug_identifiers. [ $+ [ $cid ] ],$2,32) 
    }
  }
}
alias debug_multiplex { .signal -n DEBUG $1- | return $1- }
ON *:CONNECT:.debug -i nul debug_multiplex
on *:EXIT:unset %debug_outputs.* | unset %debug_identifiers.*

on *:SIGNAL:DEBUG: {
  var %i = 1
  while ($gettok(%debug_outputs. [ $+ [ $cid ] ],%i,32)) {
    var %output = $v1
    if (%output != nul) $iif(@* iswm %output,echo,write) %output $1-
    inc %i
  }
  var %i = 1
  while ($gettok(%debug_identifiers. [ $+ [ $cid ] ],%i,32)) { 
    var %name = $v1
    if ($isalias(%name)) %name
    inc %i 
  }
}


Certainly not perfect, but should be workable.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Link Copied to Clipboard