1 - if you will remove all the HTML tags, doesnt need to put $null
2 - if you will use tokenize, why did you use $gettok so? instead using $1 $2 and $3?
3 - you dont need to do a lot of vars like on hhfree alias... just return the value of all the commands
4 - there is no reason to use alias GetDefineSearch when you can do the same command on the on text event
5 - no need to use timers, and then do a noop command just to flood control
6 - whats the reason for the $ticks on $regsubex, if you will not call the $regsubex name after?
7 - you are a newbie, accept the advices
8 - if you want to make it a challenge, we can short it a lot, check my example, shorter and with some modifications
alias -l hhfree {
return $replace($regsubex($regsubex($1-,/<[^>]+>/g,),/&#(\d+);/g,$chr(\1)), ,$chr(32),",")
}
On $*:Text:/^(!|@)Define.*/Si:#:{
if ($($+(%,define,$wildsite,$network),2) = 1) { .notice $nick Please wait 6 seconds to trigger this command again. | return }
else {
set -u6 $+(%,define,$wildsite,$network) 1
var %sockname = $+(define,$network,$2,$ticks)
sockopen %sockname oxforddictionaries.com 80
sockmark %sockname $iif($regml(1) == !,.msg $chan,.notice $nick) $2-
}
}
on *:sockopen:define*:{
tokenize 32 $sock($sockname).mark
if (!$sockerr) {
var %x = sockwrite -nt $sockname
%x GET $+(/definition/,$3,?q=,$3) HTTP/1.1
%x Connection: close
%x Host: $+($sock($sockname).addr,$str($crlf,2))
}
else { $1-2 $sock($sockname).addr is having some technical difficulties. }
}
on *:sockread:define*:{
tokenize 32 $sock($sockname).mark
if ($sockerr) { $1-2 $sock($sockname).addr is having some technical difficulties. }
else {
var %define
sockread %define
if ($regex(%define,/<span class="definition">(.*?)<\/span>/)) {
$1-2 Definition: $hhfree($regml(1))
}
if ($regex(%define,/<span class="exampleGroup exGrBreak"> <em class="example"> (.*?)<\/em><\/span>/)) {
$1-2 Example: $hhfree($regml(1))
}
if (*Page not found* iswm %define) {
$1-2 No Results have been found for: $qt($3) | sockclose $sockname
}
}
}