Auto Away on Idle
Platform: mIRC
Published Jan 04, 2006
Updated 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
}
}