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

#	Copyright (c) 2006 EPIC Software Labs
#	Written by BlackJac@EFNet
#
#	Version: 2.0.2006.06.08.1
#
#	This script will automatically complete a partially matching
#	nickname when you type it in a channel.
#
#	Settings:
#		set nickcomp [on|off|toggle]
#			Turns nick completion on or off.
#		set nickcomp_char [<character>]
#			Use this character to indicate a nick completion
#			should be attempted.
#		set nickcomp_len [<positive integer>]
#			Require at least this many input characters in order
#			to attempt a nick completion.
#		set nickcomp_multi [on|off|toggle]
#			Determines whether a nick completion should return
#			multiple matching nicks in a comma-separated list, or
#			just the first match.

package nickcomp;

load addset;

addset nickcomp bool {
	if (*0 == 'on') {
		alias nickcomp (pattern, void) {
			if (pattern) {
				if (onchannel($pattern $C)) {
					return $pattern($pattern $onchannel($C));
				};
				if (:nicklist = pattern($pattern* $onchannel($C))) {
					return ${getset(nickcomp_multi) == 'on' ? unsplit(, $nicklist) : word(0 $nicklist)};
				};
				return $pattern;
			};
		};
		^on ^input '%$$getset(nickcomp_char) *' {
			@ :nick = before($getset(nickcomp_char) $0);
			sendline ${@nick >= getset(nickcomp_len) ? nickcomp($nick) : nick}$getset(nickcomp_char) $1-;
		};
	} else if (@) {
		alias -nickcomp;
		^on ^input -'%$$getset(nickcomp_char) *';
	};
};

set nickcomp on;

addset nickcomp_char str;

set nickcomp_char :;

addset nickcomp_len int;

set nickcomp_len 3;

addset nickcomp_multi bool;

set nickcomp_multi off;
