/*
 * A webster client for ircII
 * Written by Jeremy Nelson (C) 1994 - This is Freeware
 *
 * This script requires ircII2.3.16+10 or better to run.
 * Yes, this *is* an ircII script.
 */
alias define {
	webster.connect
	webster.out DEFINE $0
}
alias complete {
	webster.connect
	webster.out COMPLETE $0
}
alias endings {
	webster.connect
	webster.out ENDINGS $0
}
alias spell {
	webster.connect
	webster.out SPELL $0
}
alias webster.out {
	dcc raw $webster.fd $webster.host $*$chr(13)$chr(10)
}
alias webster.connect {
	^set display off
        eval echo *** Webster: Hang on.....
	@ webster.host = [moose.cs.indiana.edu]
	@ webster.port = 2627
	@ webster.fd = connect($webster.host $webster.port)
	if (webster.fd)
	{
		eval ^on ^dcc_raw "$webster.fd $webster.host D *" {
			hook WEBSTER $strip($chr(13) $3-)
		}
	}
	{
		echo *** Webster: connection failed
	}
	^set display on
}

# The DEFINE command replies
on hook "WEBSTER DEFINITION 0" {
	echo *** Webster: Definition Found.
}
on hook "WEBSTER DEFINITION %" {
	echo *** Webster: There are $2 cross references for this word
}
on hook "WEBSTER WILD" {
	echo *** Webster: These words match the pattern.
}
on hook "WEBSTER WILD 0" {
	echo *** Webster: No words match this pattern.
}
on hook "WEBSTER ERROR*" {
	echo *** Webster: Error: unknown command. Ack!
}

# The COMPLETE command replies
on hook "WEBSTER AMBIGUOUS %" {
	echo *** Webster: There are $2 possible completions to the word.
}
on hook "WEBSTER COMPLETION %" {
	echo *** Webster: Try completing the word as $2.
}

# The ENDINGS command replies
on hook "WEBSTER MATCHS 0" {
	echo *** Webster: No words begin with that prefix
}
on hook "WEBSTER MATCHS" {
	echo *** Webster: These words complete that suffix
}

# The SPELL command replies
on hook "WEBSTER SPELLING 0" {
	echo *** Webster: I have NO idea how to spell that word
}
on hook "WEBSTER SPELLING 1" {
	echo *** Webster: That word is spelled correctly
}
on hook "WEBSTER SPELLING" {
	echo *** Webster: Try using one of these words instead
}

# Everything else gets echoed
on hook "WEBSTER *" {
	echo $1-
}
