All pastes #21347 Raw Edit

Someone

public text v1 · immutable
#21347 ·published 2005-08-28 05:02 UTC
rendered paste body
on *:TEXT:!spell*:#:{
  set %spell.chan $chan 
  check.spelling $2-
}
alias check.spelling {
  if ($1 == !help) { .timer 1 0 msg $chan !ignore <ignoreword>, !coff, !con, !nocorrect, !correct | return }
  if ($1 == !ignore) { write ignore.txt $2 | .timer 1 0 msg $chan the word " $+ $2 $+ " will be ignored from now on. | return }
  if ($1 == !coff) { %nocorrect = $true | .timer 1 0 msg $chan Correct Bot Off. | return }
  if ($1 == !con) { unset %nocorrect | .timer 1 0 msg $chan Correct Bot On. | return }
  if ((%nocorrect) || ($1- != $strip($1-))) { return }
  if ($1 == !nocorrect) { %donotcorrect = %donotcorrect $nick | .timer 1 0 msg $chan You won't be corrected. | return }
  if ($1 == !correct) { %donotcorrect = $remove(%donotcorrect,$nick) | .timer 1 0 msg $chan You will now be corrected. | return }
  if ($nick isin %donotcorrect) { return }
  var %sents = $remove($strip($1-),.,?,:,;,",*,&,^,%,$,#,@,!,'s,'ll,'ve",1,2,3,4,5,6,7,8,9,0,+,_,/,\,$chr(44)), %i = $numtok(%sents,32)
  var %sents = $replace(%sents,-,$chr(32))
  while (%i >= 1) {

    if (!$read(ignore.txt, s, $gettok(%sents,%i,32))) do.check.word $gettok(%sents,%i,32)
    dec %i
  }
}
alias word.site { return http://dictionary.reference.com/search?q= $+ $1 }
alias httpparse {
  if ($regex($1-, http:\/\/(?:(?:[^:]+)(?::(?:.+))?@)?([^/]*)(\/.*) )) {
    if ($prop == site) return $regml(1)
    if ($prop == file) return $regml(2)
  }
}
alias do.check.word {
  var %spelling.sock = spelling. $+ $1
  if ($sock(%spelling.sock)) { return }
  sockopen %spelling.sock $httpparse($word.site($1)).site 80
  sockmark %spelling.sock $word.site($1)
}
on *:SOCKOPEN:spelling.*: {
  if ($sock($sockname)) {
    sockwrite -n $sockname GET $httpparse($sock($sockname).mark).file HTTP/1.1
    sockwrite -n $sockname Host: $httpparse($sock($sockname).mark).site
    sockwrite -n $sockname Connection: Keep-Alive
    sockwrite -n $sockname $crlf
  }
}
on *:SOCKREAD:spelling.*: {
  var %d, %link, %info
  sockread %d
  if (%d == $null) { return }
  if (<h2 style="margin-bottom: 2em;">*entr*found for <i>*</i>.</h2> iswm %d) { 
    if ($gettok($gettok(%d,3,32),2,62) isnum) {
      msg %spell.chan $remove($sockname,spelling.) is correct 
    }
    elseif ($gettok($gettok(%d,3,32),2,62) == No) { msg %spell.chan $remove($sockname,spelling.) is incorrect }
  }
  if (<p>Did you mean <a href="*">*</a>?</p>* iswm %d) if ($regex(%d,/Did\syou\smean\s\<a[^\>]*\>([^\<]*)\<\/a\>/)) msg %spell.chan Did you mean: $regml(1) $+ ?
}