here is one way of making it
trigger @def <number of def's> Ex:" @def cat 2 " to message the channel
or " !def cat 2 " to notice the user
on $*:text:/^([@!])def\s(\w+)\s(\d+)$/iS:#: {
if ($sock(def)) sockclose def
if ($hget(def)) .hfree def
sockopen def lookwayup.com 80
sockmark def $iif($regml(1) == @,msg #,.notice $nick) $regml(2) $regml(3)
}
on *:sockopen:def: {
sockwrite -nt $sockname GET $+(/lwu.exe/lwu/d?s=f&w=,$gettok($sock(def).mark,3,32)) HTTP/1.1
sockwrite -nt $sockname Host: $+(lookwayup.com,$str($crlf,2))
}
on *:sockread:def: {
var %def | sockread %def
if ($regex(%def,/^(not found.)/)) { $gettok($sock(def).mark,1-3,32) $regml(1) | sockclose def }
if ($regex(%def,/<tr><td class="dict_text">.+">\d\.<\/b>(.+)/)) { $gettok($sock(def).mark,1-3,32) $regml(1) }
if ($regex(%def,/^\t<b>(.+)<\/b>$/)) { $gettok($sock(def).mark,1-2,32) $regsubex($regml(1),/&#(\d+);/g,$chr(\1)) | .hinc -m def num 1 }
if ($hget(def,num) == $gettok($sock(def).mark,4,32)) { sockclose def | if ($hget(def)) .hfree def }
}
Just one of many ways to make this.
also one way to replace them " i did
$regsubex($regml(1),/&#(\d+);/g,$chr(\1))
in my version
but if you wanted to use it as a alias you can do
alias -l rchr { var %rchr = $1- | return $regsubex(%rchr,/&#(\d+);/g,$chr(\1)) }
that way you dont need to do all them $replace(%define,,,$chr(44)) and so on you can just do $rchr(%define) or w/e you use to hold the info.