Here you go, Rick:
on $*:text:/^!define o(n|ff)$/iS:#:{
if ($nick isop #) {
if ($regml(1) == n) {
if (!$istok(%chan,#,44)) {
set %chan $addtok(%chan,#,44)
.notice $nick # has been added!
}
else .notice $nick the channel $qt(#) has already been added!
}
else {
if ($istok(%chan,#,44)) {
set %chan $remtok(%chan,#,1,44)
.notice $nick # has been removed.
}
else .notice $nick the channel $qt(#) has already been removed.
}
}
else .notice $nick Access Denied. This command is reserved for OP only.
}
on *:sockopen:ud*:{
tokenize 32 $sock($sockname).mark
if ($sockerr) {
$5-6 Socket Error!
halt
}
$2-4 GET $+(/v0/define?term=,$1) HTTP/1.0
$2-4 Host: $+($sock($sockname).addr,$str($crlf,2))
$2-4 Connection: close
}
on $*:text:/^[!@.]define( |$)/iS:%chan,?:{
if (!$($+(%,-,$site,.,$cid,.,$nick),2)) {
inc -u3 $+(%,-,$site,.,$cid,.,$nick)
var %ud = $+(ud,$str($ticks,3))
$+(sock,$iif($sock(%ud),close,open) %ud api.urbandictionary.com 80)
sockmark %ud $replace($strip($2-),$chr(32),+) $&
sockwrite -nt %ud .msg $iif(#,#,$nick)
}
}
on *:sockread:ud*:{
sockread &ud
tokenize 32 $sock($sockname).mark
if ($sockerr) {
$5-6 Socket Error!
}
elseif (no_results isin $bvar(&ud,1-).text) {
$5-6 $qt($1) is undefined!
}
elseif ($regex($bvar(&ud,1-).text,/"definition":"(.*)/)) {
tokenize 34 $regml(1)
$gettok($sock($sockname).mark,5-6,32) $regsubex($1,/\Q\r\n\E/g,$chr(32))
}
}