Auto Away on Idle

By RusselB on Jan 04, 2006

This permits a user to set a specific nick & away message to become their nick & away message if they are idle on a network for a specific amount of time. Nick, Away Message and Idle time are customizable to each network. There's also a check box to turn the idle check on/off, which, again, is on a network by network basis.

I have tested this with up to 4 networks with the biggest problem being up to a 30 second lag in the change.

Code will auto-execute upon start/load, plus there's menu access.

If you're already connected to one or more networks, these networks will be added to the list of networks (in the dialog) automatically.

Please let me know if you discover any problems, so that I can get them repaired as soon as possible.

/*
Multiple network auto away on idle system
Written by RusselB
Thanks to hixxy & xDaeMoN for their assistance
*/
on *:start:{
  if !$hget(Idle_Away) { .hmake Idle_Away 10 }
  if $exists(Idle_Away.hsh) { .hload Idle_Away Idle_Away.hsh }
  idle_away
}
on *:exit:{
  .hsave -o Idle_Away Idle_Away.hsh
}
on *:disconnect:{
  .hsave -o Idle_Away Idle_Away.hsh
}
menu * {
  .Idle & Away:  idle_away
}
alias idle_away { 
  if !$dialog(idle_away) { 
    dialog -mdi Idle_Away Idle_Away 
    var %connections = $scid(0), %sc 
    while %connections { 
      %sc = $scid(%connections).network 
      if !$timer($+(idle.,%sc)) && $hget(Idle_Away,$+(Active.,%sc)) && $did(Idle_away,70).state { 
        $+(.timeridle.,%sc) 0 30 myidle %sc 
      } 
      .hadd -m Idle_Away $+(Network.,%sc) %connections
      dec %connections 
    } 
  } 
  else { 
    dialog -evh Idle_Away 
  } 
} 
on *:connect: { 
  did -a Idle_Away 30 $network
  .hadd -m Idle_Away $+(Network.,$network) $cid
}

alias -l myidle { 
  var %f = $1 
  tokenize 32 $hget(Idle_Away,%f) 
  .scid $sc(%f).id 
  if ($me != $1) && ($idle > $2) { 
    .nick $1 
    .away $3 
    .scid -r 
  } 
} 
dialog Idle_Away { 
  title "Idle & Away" 
  size -1 -1 115 88 
  option dbu 
  button "Store", 10, 5 5 20 10, default 
  button "Delete", 20, 30 5 20 10 
  text "Network", 1, 5 20 50 10, center 
  combo 30, 5 30 50 50, edit drop 
  edit "Nick", 40, 60 20 50 10, center 
  edit "Idle Time", 50, 60 35 50 10, center 
  edit "Away Message", 60, 60 50 50 10, center 
  check "Away on Idle?", 70, 60 65 50 10, left 
} 
on *:dialog:idle_away:*:*:{ 
  if ( $devent == init ) { 
    did -b $dname 10,20,40,50,60,70 
    did -r $dname 30 
    var %network = 1
    while $scid(%network).network { 
      did -a $dname 30 $v1 
      inc %network 
    } 
  } 
  elseif ( $devent == sclick ) { 
    if ( $did == 30 ) { 
      tokenize 32 $hget(Idle_Away,$did(30)) 
      did -ra $dname 40 $iif($1,$1,Nick) 
      did -ra $dname 50 $iif($2,$2,Idle Time) 
      did -ra $dname 60 $iif($3,$3,Away Message) 
      did $iif($hget(Idle_Away,$+(Active.,$did($did))),-ec,-eu) $dname 70 
      did $iif($hget(Idle_Away,$+(Active.,$did($did))),-e,-b) $dname 10,20,40,50,60 
    } 
    elseif ( $did == 10 ) { 
      if $did(30) { 
        hadd -m Idle_Away $did(30) $iif($did($dname,40),$v1,$sc($did(30)).me) $did(50) $did(60)
        hadd -m Idle_Away $+(Active.,$did(30)) $did(70).state 
        if !$timer($+(idle.,$did(30))) { 
          $+(.timeridle.,$did(30)) 0 30 myidle $did(30) 
        } 
      } 
      else did -f $dname 30 
    } 
    elseif ( $did == 20 ) { 
      did -u $dname 70 
      hdel Idle_Away $+(Active.,$did(30)) 
      hdel Idle_Away $did(30) 
      defset $dname 
      if ( $timer($+(idle.,$did(30))) ) $+(.timeridle.,$did(30)) off 
    } 
    elseif ( $did == 70 ) && $did(30) { 
      if ( !$did($did).state ) defset $dname 
      else { 
        did -er $dname 40,50,60 
        did -e $dname 20 
      } 
    } 
  } 
  elseif ( $devent == edit ) { 
    did $iif($duration($did(50)) isnum,-e,-b) $dname 10 
  } 
} 

alias -l defset { 
  $+(.timeridle.,$did(30)) off
  did -rba $1 40 Nick 
  did -rba $1 50 Idle Time 
  did -rba $1 60 Away Message 
} 

alias -l sc { 
  var %o = 1
  while $1 == $scid(%o).network { 
    return $iif($prop == id,%o,$scon(%o).me)
    inc %o 
  } 
} 
Sign in to comment.
RusselB   -  Dec 04, 2010

There were some unexpected changes in the latest versions of mIRC, which caused this code (and a few others) to stop working. I am in the process of re-writing the code(s) so that it/they will work with all versions, but expect it to take about a week all things considered.

So you can wait, or use mIRC version 6.21-6.35

 Respond  
Carrera   -  Dec 04, 2010

If you could just tell me what I have to do to make it work I would appreciate it thank you! I'm still new at this.

 Respond  
RusselB   -  Nov 26, 2010

The most recent problems noted regarding this code are rarities rather than common occurrences. If you have come across a specific problem with the script (or more than one), please let me know in detail what the problem is, along with any error messages that you may get, and I will do my best to rectify the situation as quickly as I can.

I also noted that there have been no further problems mentioned in over 4 years of this code being available.

 Respond  
Carrera   -  Nov 26, 2010

RusselB did you or anyone ever fix the problem in the script that won't let it work the way it was intended? If anyone knows how to make this script work could you help? I would appreciate it. thanks

 Respond  
Gex   -  Feb 24, 2006

RusselB when RoninWarrior said \"needs dialog alignment and some wasted space issues\" he didnt say sth wrong maybe alignment isnt so important but he is rite the dialog u made isnt aligned perfectly and when he said wasted space he meant wasted space in the dialog design like the space down to the combo box...anyway in Dialog studio there is Alignment options like the visual basic one\'s choose 2 or 3 controls then rite click then alignment and there u can find the options which will give u 100% good looking better. sth else i wanna say. roninwarrior didnt say its bad snippet and he refered to some drawbacks in the dialog and this is sth i respect for a reason; when i rate a script the first thing i look to is the quality of the code and its functionality the second thing is the design if exists.like in mirc.net exactly gives score on design / functionality . @yoinx roninwarrior didnt say sth wrong the dialog needs to be modified if someone has worked or sold vb project b4 u would know what ronin means.most of programers write the code and let the designers design the forms/menus etc..

 Respond  
RusselB   -  Feb 24, 2006

khigh: The only ways that I can see that line returning that error is A) You have tried running the script from a fresh start of mIRC without connecting B) You happen to have hit one of the few networks that doesn\'t return a value for $network (I understand that they do exist, but I haven\'t found one)

My apologies for not responding to this sooner..it was actually a fluke that I was referring someone else to this script and I needed the actual snippet ID

 Respond  
RoninWarrior   -  Feb 04, 2006

DBU Height - 2 - DBU Width - 2 RES 1280 by 720 windows XP pro when i complain about someones dialog it doesnt mean that the dialog is ugly im just real picky about everything in a dialog being perfectlt aligned is all RussleB dialog on a scale of 1-10 is about 8.5 which is darn near perfect if you load your MP3 and Xdeamon mp3 player you will see there about 9.5-9.7 with being perfect but what is perfect to me ,might be junk to you and others

 Respond  
nobody   -  Jan 09, 2006

It\'s simple and clean; and that\'s why I like it. =D

 Respond  
Yoinx   -  Jan 07, 2006

i would assume the same... but... supposedly the dbu value is supposed to change to a different number of pixels for each resolution.. I dont really know... maybe you have to re-open mirc to get the values to change? I just started using pixels for my dialogs instead. shrug

 Respond  
RusselB   -  Jan 07, 2006

Yoinx: thanks for that little echo code. Using it and adjusting my video to multiple settings, I checked my own levels, and got the same as you did. The resolutions that I checked are: 800x600, 960x600, 1024x768, 1152x864, 1280x720, 1280x768, 1280x800, 1280x960, 1280x1024, 1360x768, 1600x900, 1600x1024, & (finally) 1600x1200

I was unable to get my monitor to go to a lower resolution than 800x600, but, in theory, if I\'m getting 2 pixels/dbu with all of those, then I should get the same with anything lower.

 Respond  
Yoinx   -  Jan 07, 2006

Ronninwarrior, since you\'re the only person that i\'ve seen complain about anyone\'s dialogs.

//echo -a DBU Height - $dbuh - DBU Width - $dbuw

can you type that and let me know what you get. I have 2 pixels per dbu on my laptop. its at 800x600 (i know...)

Im just kinda curious what yours is set to.

 Respond  
RusselB   -  Jan 06, 2006

Please clarify what you mean by \"dialog alignment\" and \"wasted space\". I thought I had the dialog well lined up. If you know of a way so that the dialog could be automatically aligned based on a person\'s preference, let me know, and I\'ll be glad to add it to the code, and your name to the credits. As to wasted space, where do you mean? If you\'re referring to the space for the hash tables, INI files were suggested, but I decided to not go with them.

 Respond  
RoninWarrior   -  Jan 05, 2006

this is a pretty simple away system that supports any server for idle away very nice job RussleB

needs dialog alignment and some wasted space issues

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.