/*
 * follow, 1993
 * You guessed it -- this requires EPIC.
 */
alias clrit {
	stack pop on 311
	stack pop on 314
	stack pop on 312
	stack pop on 401
	stack pop on 406
}
alias followuh {
	stack push on 311
	stack push on 314
	stack push on 406
	stack push on 401
	stack push on 312
	^on ^311 "% % *" {@ function_return [$2];clrit}
	^on ^314 "% % *" {@ function_return [$2];clrit}
	^on ^406 "% % *" {@ function_return [NONE@NONE.NONE];clrit}
	^on ^401 "% % *" :
	^on ^312 "% % *" :

	@ tmpfoo = AUTO_WHOWAS
	^set AUTO_WHOWAS ON
	whois $0
	wait
	wait		/* Requires TWO waits in case a WHOWAS is done */
	^set AUTO_WHOWAS $tmpfoo
}
alias follow {
	@ nicks = []
	@ whatis = show_end_of_msgs
	^set show_end_of_msgs OFF
	@ followed = followuh($0)
	if (followed == [NONE@NONE.NONE])
	{   echo No luck.  Cannot follow }
	{
		stack push on who
		^on ^who * push nicks $$1
		eval who $followed
		wait
		stack pop on who
	}
	@ function_return = nicks
	^set show_end_of_msgs $WHATIS
}

alias ffollow {
        @ nicks = []
        @ followstuff = followuh($0)
        @ tchannel = [$1]?[$1]:[$C]
        @ user_hosts = uh($onchannel($tchannel))
        @ nicks = copattern($followstuff $user_hosts $onchannel($tchannel))
        @ function_return = nicks
}
