if (word(2 $loadinfo()) != [pf]) { load -pf $word(1 $loadinfo()); return; };

#
# Here's the plan...
#
#  /notify nick1 nick2 nick3
# or
#  /notify -nick -nick2 -nick3
#
# These are bare wrappers on top of MONITOR.
#
# wcarson asked for WATCH.
# WATCH works like this:
#   WATCH +nick
#   WATCH -nick
# I need to figure out how to interpret what it returns
#  WATCH +hoponpop
#  :lair.nl.eu.dal.net 604 hOponpop hOponpop jnelson b1b2-e743-e08d-4672-e0b3.epicsol.org 1741576499 :is online
#  WATCH -hoponpop
#  :lair.nl.eu.dal.net 602 hOponpop hOponpop jnelson b1b2-e743-e08d-4672-e0b3.epicsol.org 1741576523 :stopped watching
#  WATCH
#  :lair.nl.eu.dal.net 607 hOponpop :End of WATCH l
#  WATCH +hoponpop
#  :lair.nl.eu.dal.net 604 hOponpop hOponpop jnelson b1b2-e743-e08d-4672-e0b3.epicsol.org 1741576553 :is online
#  NICK hop4
#  :hOponpop!jnelson@b1b2-e743-e08d-4672-e0b3.epicsol.org NICK :hop4
#  :lair.nl.eu.dal.net 601 hOponpop hOponpop jnelson b1b2-e743-e08d-4672-e0b3.epicsol.org 1741576557 :logged offline
#

alias monitor { quote monitor $* };

on ^730 * { echo *** $1- is online };
on ^731 * { echo *** $1- is not online };

alias notify {
	if (serverctl(GET -1 005 MONITOR)) {
		if (* == []) {
			monitor s
		} elsif (* == '-') {
			monitor c
		} else {
			^local removals,additions;

			# Sort them into two buckets
			fe ($*) x {
				if (left(1 $x) == '-') {
					push removals $mid(1 999 $x);
				} elsif (left(1 $x) == '+') {
					push additions $mid(1 999 $x);
				} else {
					push additions $x;
				}
			};
			if (additions) {
				monitor + $additions;
			} elsif (removals) {
				monitor - $removals;
			};
		};
	} else {
		xecho -b This server does not support MONITOR which is used by /NOTIFY;
	};
};

#hop'2k25
