on *:TEXT:*:#mychan:{ check.spelling $1- }
on *:Input:#mychan:{ check.spelling $1- }
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 (<td><h2 style="margin-bottom: 2em;">* entr* found for <i>*</i>.</h2> iswm %d) { }
if (<p>Did you mean <a href="*">*</a>?</p>* iswm %d) if ($regex(%d,/Did\syou\smean\s\<a[^\>]*\>([^\<]*)\<\/a\>/)) msg #mychan " $+ $remove($sockname,spelling.) $+ " is not a word, $gettok($insult, $rand(1,$numtok($insult,$asc(.))), $asc(.)) $+ . Did you mean: $regml(1) $+ ?
}
alias insult { return moron.idiot.gimp.smegma chewer.dumbsh!t.reject.f_ckhead.darwin disproof.retard.dumber than chalk.Andromeda watcher.silly goose.brainless git.used car salesperson.liver lover }