This little snippet will check your spelling of a word and if it is incorrect it will list out some optional spellings/words for you to chose from.
!Spell word
on *:text:!spell*:#: {
if (!%sspell) {
inc -u5 %sspell
set %spellchannel $chan | set %spellword $2
sockopen spellcheck www.infoplease.com 80
}
}
on *:sockopen:spellcheck: {
sockwrite -n $sockname GET $+(/spellcheck?word=,%spellword) HTTP/1.1
sockwrite -n $sockname Host: www.infoplease.com
sockwrite -n $sockname Connection: close
sockwrite -n $sockname Authorization: Basic
sockwrite -n $sockname $crlf
}
on *:sockread:spellcheck: {
sockread %temp
if (is spelled correctly isin %temp) { set %spellcorrect on }
if (Hmmm… isin %temp) { set %spellcorrect off }
if (<li>*</li> iswm %temp) { window -nk0 @Spelling | inc %ss 1 | aline @Spelling $nohtml(%temp) }
}
on *:sockclose:spellcheck: {
if (%spellcorrect == on) {
msg %spellchannel The word $qt(%spellword) is spelled correctly.
unset %spell* %ss %temp | .timer 1 1 window -c @Spelling
}
if (%spellcorrect == off) {
if ($gettok($line(@Spelling,1),1,58) = Daily Word Quiz) {
msg %spellchannel There are no suggestions for $qt(%spellword)
unset %spell* %ss %temp | .timer 1 1 window -c @Spelling
}
else {
msg %spellchannel Hmmm... that does not look right. Here are some possible alternate spellings:
var %t 1 | while (%t <= $calc($fline(@Spelling,Daily*,1) -1)) {
var %spellingfixes $addtokcs(%spellingfixes,$remove($mid($line(@Spelling,%t),1,$len($line(@Spelling,%t))),$chr(40),$chr(41),definition),44)
inc %t
}
var %spellingfixes $replace(%spellingfixes,$chr(44),$+($chr(44),$chr(32)))
msg %spellchannel [Word(s)]: $colored(%spellingfixes,12)
unset %spell* %ss %temp | .timer 1 1 window -c @Spelling
}
}
}
alias nohtml {
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, )
return %x
}
; Usage: $colored(TEXT,N1,N2) or $colored(TEXT,N1,N2).b
; N1 & N2 are both optional.
alias colored { if ($isid) { return $+($iif($prop = b,$chr(2)),$iif($2 isnum 0-15,$+($chr(3),$iif($len($2) == 1,$+($chr(48),$2),$2))),$iif($3 isnum 0-15,$+($chr(44),$iif($len($3) == 1,$+($chr(48),$3),$3))),$1,$chr(15)) } }