rendered paste bodyalias -l htmlfree {
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, )
return %x
}
on *:INPUT:*:{
if ($1 == !define) {
if ($2 != $null) {
if ($sock(define) != $null) { sockclose define }
unset %a
sockopen define wordnet.princeton.edu 80
set %search $replace($2-,$chr(32),$+($chr(37),20))
set %chanmsg $active
}
}
}
on *:text:*!define*:#:{
if ($2 != $null) {
if ($sock(define) != $null) { sockclose define }
unset %a
sockopen define wordnet.princeton.edu 80
set %search $replace($2-,$chr(32),$+($chr(37),20))
set %chanmsg $chan
}
}
on *:sockopen:define:{
sockwrite -nt $sockname GET /perl/webwn?s= $+ %search HTTP/1.1
sockwrite -nt $sockname Accept-Language: en-us
sockwrite -nt $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20040913 Firefox/0.10.1
sockwrite -nt $sockname Referer: http://wordnet.princeton.edu
sockwrite -nt $sockname Host: wordnet.princeton.edu
sockwrite -nt $sockname Connection: keep-alive
sockwrite -t $sockname $str($crlf,2)
}
on *:sockread:define:{
if ($sockerr > 0) { return }
:nextread
sockread %temp
if ($sockbr == 0) {
return
}
if (%temp == $null) { %temp = - }
var %x = did not return any
if (%x isin $htmlfree(%temp)) { msg %chanmsg 1|Define|4 No Results Found | halt }
if (S: isin $htmlfree(%temp)) {
if (SEARCH DISPLAY OPTION == $remove($htmlfree(%temp),S:,)) { goto nextread }
if (KEY isincs $remove($htmlfree(%temp),S:,)) { goto nextread }
if (%a == $null) { set %a 1 }
if (%a < 3) {
msg %chanmsg 1|Define|4 $remove($htmlfree(%temp),S:,) $+
inc %a 1
}
}
goto nextread
}