Spellcheck

By Scakk on May 28, 2012

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,&nbsp;)
  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)) } }

Comments

Sign in to comment.
Blackkatt   -  Apr 23, 2013

Hi, how to get it working?

 Respond  
Scakk   -  Apr 10, 2013

Updated: Added a check if there is nothing suggested. Made actually list out all the suggestions.

 Respond  
cptpan   -  Aug 25, 2012

This is good. Thanks

 Respond  
Scakk   -  May 31, 2012

I just tested using your word and got

[13:29] <Goofy|AFK> !spell communifate
[13:29] Hmmm... that does not look right. Here are some possible alternate spellings:
[13:29] [Word(s)]: 12communicate, Communist, communist, communicator, community, commentate

 Respond  
Beautifulll   -  May 31, 2012

"communifate"

 Respond  
Scakk   -  May 30, 2012

What did you use when you got no result?

 Respond  
Beautifulll   -  May 30, 2012

it did not show the anything after the : in Hmmm... that does not look right. Here are some possible alternate spellings:

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.