mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The following dialog is supposed to show total idle times at the top of each column and individual idle times for the selected nick(s) in the last column, with the idle time showing beside the appropriate nick.
Code:
 dialog Idle {
  title "Idle Time"
  size -1 -1 259 141
  option dbu
  text "Network", 1, 5 5 50 8, center
  edit "", 2, 5 15 50 10, read center
  list 3, 5 27 50 50
  text "Channel", 4, 60 5 50 8, center
  edit "", 5, 60 15 50 10, read center
  list 6, 60 27 50 50
  text "Name/Nick", 7, 115 5 50 8, center
  edit "", 8, 115 15 50 10, read center
  list 9, 115 27 50 50, multsel
  list 10, 170 27 50 50
  button "OK/Cancel", 11, 170 15 50 10, ok cancel default
}
menu * {
  &Idle Time2: idle.time
}
alias -l idle.time {
  dialog $iif(!$dialog(Idle),-md,-ev) Idle Idle
}
on *:dialog:Idle:Init:*:{
  did -r $dname 2,3,5,6,8,9,10
  var %a = 1, %b = $scon(0)
  while %a <= %b {
    if $scon(%a).status == connected {
      did -a $dname 3 $scon(%a).network
    }
    inc %a
  }
}
on *:dialog:Idle:sclick:3:{
  set %connection $did(3).sel
  .scon %connection
  did -r $dname 2,5,6,8,9,10
  var %a = 1, %b = $chan(0)
  while %a <= %b {
    did -a $dname 6 $chan(%a)
    unset %idle.channel
    var %c = $nick($chan(%a),0)
    while %c {
      inc %idle.channel $nick($chan(%a),%c).idle
      dec %c
    }
    inc %idle.network %idle.channel
    inc %a
  }
  did -ra $dname 2 $d2(%idle.network)
}
alias -l d2 {
  var %idle = $duration($1)
  return $iif($numtok(%idle,32) < 4,$duration($1,3),$+($gettok(%idle,1--3,32),$chr(32),$duration($duration($gettok(%idle,-3-,32)),3)))
}
on *:dialog:idle:sclick:6:{
  .scon %connection
  did -r $dname 5,8,9,10
  set %chan $did(6).seltext
  var %a = 1, %b = $nick(%chan,0)
  unset %idle.channel
  while %a <= %b {
    did -a $dname 9 $nick(%chan,%a)
    inc %idle.channel $nick(%chan,%a).idle
    inc %a
  }
  did -ra $dname 5 $d2(%idle.channel)
}
on *:dialog:idle:sclick:9:{
  .scon %connection
  if !$did(9,0).sel {
    did -r $dname 8,10
    unset %idle.nick
  }
  else {
    var %a = 1, %b = $did(9,0).sel
    while %a <= %b {
      var %nick = $did(9,%a).seltext
      did -o $dname 10 $did(9,%a).sel $d2($nick(%chan,%nick).idle)
      inc %idle.nick $nick(%chan,%nick).idle
      inc %a
    }
    did -ra $dname 8 $d2(%idle.nick)
  }
}
 

Joined: Mar 2004
Posts: 21
Ameglian cow
Offline
Ameglian cow
Joined: Mar 2004
Posts: 21
And where the code does not work ?

For the moment:

* Little optimization: instead of this code in your INIT :
Code:
var %a = 1, %b = $scon(0)
  while %a <= %b {
    if $scon(%a).status == connected {
      did -a $dname 3 $scon(%a).network
    }
    inc %a
  }

you can just use this line, which adds each connected network names :
Code:
scid -at1 did -a $dname 3 $!network

* A bug here. If you have not connected 'Status Windows' before connected ones, the $did().sel will not return a value which allows to retrieve informations about channels.
Code:
  set %connection $did(3).sel
  .scon %connection

You can try that, which puts in %x the $cid of the 1st connected server which is connected to the selected network name. But if you have many connexions on the same network it is not efficient. A good mean would be to stock somewhere the line number of your list + the associated $cid.
Code:
  scid -at1 if ( $!network == $did(3).seltext ) var $(%x $cid,)
  scid %x


Also, you could use aliases to retrieve idle of nicks and channels (your code would be smaller, and as efficient as the current one)


-Be cool with my English-
irc.EpiKnet.org:#scripts
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Sorry. The part(s) that aren't working, are
A) the display of the individual idle times for each person that is selected
B) Proper calculation of total idle time for all nicks selected

Those are the main items I'm having difficulties with.

Regarding your suggestions:
1) Thanks, I'll probably implement it.
2) That should never happen, as the list of networks should only show those networks that are actually connected.

Joined: Mar 2004
Posts: 21
Ameglian cow
Offline
Ameglian cow
Joined: Mar 2004
Posts: 21
Hi again,

I have no time to try to debug your code.

For my second suggestion, I explain :

If you have 3 'status window', eg:
* EpiKnet, connected
* Efnet, not connected
* Undernet, connected

in your dialog list, you will have :
* EpiKnet
* Undernet

If you click on EpiKnet, /scon will works well, but on Undernet, /scon will work with Efnet, which is not connected, so no efficient results. You can not execute command on Undernet, because it is on the 3rd place, and your list have just 2 lines.

I hope my explanation is not too bad.


-Be cool with my English-
irc.EpiKnet.org:#scripts

Link Copied to Clipboard