; ---------- SETUP START ----------
; setup: colour for nicks marked "away"
alias -l away.check.gone { return 14 }
; setup: colour for nicks not away
alias -l away.check.here { return 10 }
; setup: interval to check away status (seconds)
alias -l away.check.interval { return 90 }
; ---------- SETUP END ----------
; on connect, start a loop to check away status
on *:connect: { $+(.timer.away.refresh.,$network) 0 $away.check.interval away.check }
; menu switch to stop/restart the checking manually
menu status,channel {
Awaycheck $+($chr(91),$network,$chr(93))
.$iif(($timer($+(.away.refresh.,$network))),$style(1)) resume : {
away.check
$+(.timer.away.refresh.,$network) 0 $away.check.interval away.check
}
.$iif((!$timer($+(.away.refresh.,$network))),$style(1)) pause : {
$+(.timer.away.refresh.,$network) off
}
}
; checking routine
alias -l away.check {
; enable group to halt the display of raw replies related to away-checking
.enable #awaycatch
; start disabling timer for it
.timer.away.catch 1 20 .disable #awaycatch
; open a hidden window to list users marked as away
window -h @away.catch
; request list of all users marked away and sharing a chan
who +aM
}
; group to catch and halt raw replies
#awaycatch off
raw 352:*: {
; if user is marked as away, add nick to the hidden window (as precaution, check "away" again)
if (G isin $7) { aline @away.catch $6 }
; halt display of that raw reply
haltdef
}
raw 315:*: {
; end of who: execute timer that disables the group
timer.away.catch -e
; execute colouring alias
awaycatch.colour $network
; halt display of that raw reply
haltdef
}
#awaycatch end
; colouring routine
alias -l awaycatch.colour {
scon $1
; cycle all chans
var %c.nr = 1
while ($chan(%c.nr)) {
var %chan = $v1, %n.nr = 1
; cycle all nicks
while ($nick(%chan,%n.nr)) {
var %nick = $v1
; colour nick accordingly (nick is or is not listed in the window of users marked away)
cline -l $iif(($fline(@away.catch,%nick,1)),$away.check.gone,$away.check.here) %chan %nick
inc %n.nr
}
inc %c.nr
}
; close hidden window
window -c @away.catch
scon -r
}