A lot more learning, a bit of testing and refinement, more testing and refinement (thanks
yakko!) and here what might just be the (first) final version of FadeAway.
What it does: Gives mIRC the ability to indicate away and idleness of nicks.
What it looks like: I've defaulted things to look good on a black background (what I use) but have pointed out in the comments what to change for a white background. (Search for "/InitFadeAwayVariables" sans quotes and you'll find the needed bits at the second occurrence.) FadeAway does not tamper with your background color or default choice of nick color.
The default colors: An active, non-away nick will look just like it would without FadeAway. A nick idle for 10-30 minutes will be repainted blue-green. A nick idle for 30-60 minutes will be repainted light grey. A nick idle for more than 60 minutes will be painted dark grey. An away nick (whether idle or not) will be painted dark grey. If you are away, your nick is painted bright blue.
The check is done every two minutes or so. Also, whenever a nick changes it gets checked.
How to use it: Copy FadeAway into the remote section. Or copy into remote.ini and be sure remote.ini is loaded. FadeAway will take effect on the next connect.
What can break: FadeAway changes how /who and /whois act - suppressing their responses. The aliases /w for /whois and /wh for /who are provided as replacements. The "/whois $$1" in popups should be changed to "/w $$1" and the "/w /whois $$1" in aliases should be commented out (put a ; in front of it).
You sure are wordy: Overdocumentation is better than underdocumentation. The script commenting may seem verbose. If that bugs you, you can strip the comments out. Good luck if you have to debug it then, though!
; FadeAway
;
; mIRC script to color nicks of those who are away.
; (Written on/for mIRC 6.02)
; Paul Neubauer 2003
;
; What FadeAway Does:
; Scans the nicks in the channels one is on and colors them
; based on away state and idleness. Someone who is /away gets
; colored %AwayColor. If they are not away, idleness is checked.
; If idle for less than 10 minutes, the nick is left default nick
; color. If idle 10-30 minutes, the nick is colored %PauseColor.
; If idle 30-60 minutes, the nick is colored %SemiAwayColor. And
; if idle for more than 60 minutes, the nick is colored %AwayColor
; as that serious of an idle may as well be /away. This is complete
; idle, as the server reports it, not per-channel idle as can be
; checked natively in mIRC 6.03 and on.
;
; How FadeAway does it:
; Every two minutes a /who is done on all the channels one is on.
; The replies to /who are checked and /away nicks colored. Nicks
; that are not /away get a /whois done on them. The /whois replies
; check for idleness and color the nick appropriately - including
; "uncoloring" of somewhat active nicks.
;
; The outputs of /who and /whois are suppressed to prevent needless
; clutter of the Status window. The aliases /wh for /who and /w for
; /whois are provided to get non-suppressed responses.
;
; NOTE: /whois may need to be change to /w in popups and /w may have
; to be removed from aliases.
;
; Possible Interactions:
; If /w or /wh are defined elsewhere...
; If /who or /whois replies are being trapped by other scripts...
; If another script is coloring nicks with /cline...
; If mIRC is set to custom color nicks...
; If any of the global variables are used by another script...
; ...all bets are off.
;
; Gripes:
; 1. mIRC scripts don't work with proper columnar alignment of { and }.
; 2. $ial seems to be broken.
; 3. Timer(s) seem to retrigger several seconds early.
; 4. An extra if-then is needed than another else to get the /who handler to work right.
; This one might actually just be me screwing up, though.
;
;
; Timer self-triggers (0 stop) and trips every two minutes (120 seconds).
; Well, it *should* be 120 seconds. On my system, 120 of mIRC's seconds
; turns out to really be one minute and 48 seconds as the timer retriggers
; several seconds before its supposed set time. So I use 133 to get
; an interval that is if not exactly two minutes, is very close.
;
; Note that since the scan is only done every two minutes, changes in
; /away and idle status may not be reflected immediately. Once every
; two minutes seems plenty often to hammer the server with /who and
; /whois requests. It may be wise to extend the times if one is in
; several large channels simultaneously.
;
; Get things ready at connect time...
ON 1:CONNECT:{
;
; Start a timer to scan the nicks of all the channels I'm on.
/.timer 0 133 /WhoAwayScan
;
;
; Make sure the global variables get loaded.
/InitFadeAwayVariables
}
;
;
; Set initialization alias so ON:CONNECT can make sure global variables get loaded.
alias InitFadeAwayVariables {
; NOTE: My color choices are good on a BLACK background.
; A white background may need other color selections to look good.
; Recommendations listed in parenthesis.
;
; Global so that the /who and /whois traps can paint with them.
;
;
; DARK BLUE-GREEN (for white background: leave alone?) if someone is idling for a short time.
set %PauseColor 10
;
;
; LIGHT GREY (for white background: LIGHT GREY 14) if someone is idle for a little while longer.
set %SemiAwayColor 15
;
;
; DARK GREY (white background: LIGHT GREY 15) if someone is away or is in a serious idle.
set %AwayColor 14
;
;
; Unless it's me. Then LIGHT BLUE (for white background: ORANGE 7) if I'm away.
set %MyAwayColor 11
;
;
; Silence /whois (and /who) responses by default.
set %SilenceWhoIs 1
}
;
; Let /wh work for /who and get visible results, but
; don't let it bug the server if it has nothing to send.
alias wh {
if ( $1 == $null ) { /halt }
set %SilenceWhoIs 0
/who $1
}
;
; Let /w work for /whois and get visible results, but
; don't let it bug the server if it has nothing to send.
alias w {
if ( $1 == $null ) { /halt }
set %SilenceWhoIs 0
/whois $1 $1
}
;
;
; If a nick changes, check it without waiting for the timer.
ON 1:NICK:/who $newnick
;
;
; Actually do the scanning of all (the nicks on) the channels I'm on.
alias WhoAwayScan {
;
; Loop index
/var %i
;
; Nick handling - do it by channel (it seems to be more reliable that way)
; $ial should work, but seems too flaky to use if multiple channels are joined on (re)connect.
/var %NumberOfChannels
/var %CurrentChannel
/var %CurrentNick
;
; Get number of nicks on all channels I'm on.
%NumberOfChannels = $chan(0)
;
; Initialize loop index.
%i = 1
;
; Loop through all the channels I'm on.
while ( %i <= %NumberOfChannels) {
;
; Get the currently indexed channel...
%CurrentChannel = $chan(%i)
;
; ...and do a who on it. Try to be as quiet as possible about it.
/.who %CurrentChannel
;
; Increment the loop index or we'll be here forever.
inc %i
}
; Shut down, just to be sure and play nice.
/halt
}
;
; Trap the response to /who
raw 352:*:{
;
; If away, (re)color the nick.
if ( G isin $left( $7,1 ) ) {
;
; If it's me being away, quietly color my nick MyAwayColor.
if ( $6 == $me ) { /.cnick $6 %MyAwayColor }
;
; If it's anyone else being away, quietly color their nick AwayColor.
else { /.cnick $6 %AwayColor }
}
;
; If not /away have /whois do an idleness check on the nick.
if ( H isin $left( $7,1 ) ) {
/whois $6 $6
}
;
; Suppress the main /who messages to prevent cluttering up the status window.
; Unless /wh said to not be quiet.
if ( %SilenceWhoIs == 1 ) { /halt }
}
;
; Suppress "End of" data notification for /who
; but only for automatic /who . Let /wh work for manual requests.
raw 315:*:{
if ( %SilenceWhoIs == 1 ) { /halt }
; Suppress responses again. /wh can turn them back on if it wants.
else { set %SilenceWhoIs 1 }
}
;
;
; Handle the responses to /whois
; /Whois Address info Ex: Vakkotaur YakkoBat yakko akane.floop.org * Yakko J. Warner, plushie
raw 311:*:{
;
; Be quiet unless /w said not to be.
if ( %SilenceWhoIs == 1 ) { /halt }
}
;
; Nick on channels info Ex: Vakkotaur YakkoBat @#unixgeek @#watertower
raw 319:*:{
;
; Be quiet unless /w said not to be.
if ( %SilenceWhoIs == 1 ) { /halt }
}
;
; /Whois Server info Ex: Vakkotaur YakkoBat elfie.wtower.com Yallp's Hall of Geekdom
raw 312:*:{
;
; Be quiet unless /w said not to be.
if ( %SilenceWhoIs == 1 ) { /halt }
}
;
; Nick Away info Ex: Vakkotaur YakkoBat automagic away (since 11:07pm CT Mon Dec 2)
raw 301:*:{
;
; /who is really doing the work, so don't do anything about away-ness here.
;
; Be quiet unless /w said not to be.
if ( %SilenceWhoIs == 1 ) { /halt }
}
;
; /Whois IRC Operator info Ex: Vakkotaur YakkoBat is an IRC Operator
raw 313:*:{
;
; Be quiet unless /w said not to be.
if ( %SilenceWhoIs == 1 ) { /halt }
}
;
; /Whois Helpful Look info Ex: Vakkotaur YakkoBat looks very helpful.
raw 310:*:{
;
; Be quiet unless /w said not to be.
if ( %SilenceWhoIs == 1 ) { /halt }
}
;
; Idle & signon time info Ex: Vakkotaur YakkoBat 80246 1038890194 seconds idle, signon time
raw 317:*:{
;
; If nick is idle for 10 to 30 minutes, quietly paint the nick PauseColor.
if (($3 >= 600) && ($3 < 1800)) {
/.cnick $2 %PauseColor
}
;
; But if the nick is idle 30 to 60 minutes, quietly paint the nick SemiAwayColor.
elseif (($3 >= 1800) && ($3 < 3600)) {
/.cnick $2 %SemiAwayColor
}
;
; And if the nick is idle for more than 60 minutes, quietly paint the nick AwayColor.
; After all, if idle for more than an hour, someone might as well be /away .
elseif ($3 >= 3600) {
/.cnick $2 %AwayColor
}
else {
; Quietly remove the nick from the color list if not very idle.
/.cnick -r $2
}
;
; Be quiet unless /w said not to be.
if ( %SilenceWhoIs == 1 ) { /halt }
}
;
;
; Whois End info Ex: Vakkotaur yakkobat End of /WHOIS list.
raw 318:*:{
; Be quiet unless /w said not to be.
if ( %SilenceWhoIs == 1 ) { /halt }
; If not quiet, be quiet next time. /w can turn responses on again if it wants.
else { set %SilenceWhoIs 1 }
}
;
;
; No such nick or channel (nick not there) Ex: Vakkotaur Buddy No such nick/channel
raw 401:*:{
;
; Quietly remove that nick from the color list, in case it had been there.
/.cnick -r $2
;
; Be quiet unless /w said not to be.
if ( %SilenceWhoIs == 1 ) { /halt }
;
; If not quiet, be quiet next time. /w can turn responses on again if it wants.
else { set %SilenceWhoIs 1 }
}
;
;
; No such server (nick not there) Ex: Vakkotaur Buddy No such server
raw 402:*:{
;
; Quietly remove that nick from the color list, in case it had been there.
/.cnick -r $2
;
; Be quiet unless /w said not to be.
if ( %SilenceWhoIs == 1 ) { /halt }
;
; If not quiet, be quiet next time. /w can turn responses on again if it wants.
else { set %SilenceWhoIs 1 }
}
;
; End of FadeAway
And now IRC server admins can start hating me, I suppose...