on $*:text:/^[!@]Price */Si:#: {
var %item $replace($2,$chr(32),-)
var %send = $iif(!* iswm $1,notice $nick,msg $chan)
if (!$hget(Prices)) {
notice $nick lol sPrice guide not saved - command unavaliable for now
halt
}
if ($hfind(Prices,$+(*,%item,*),0,w)) {
var %matches = $v1
if (%matches == 1) || ($hget(Prices,%item)) %send Price of $+(%item,:) $hget(Prices,%item)
elseif (%matches > 10) %send Too many results - Please narrow your search
else {
while (%matches) {
echo -a $hfind(Prices,$+(*,%item,*),%matches,w)
var %msg = $addtok(%msg,$hfind(Prices,$+(*,%item,*),%matches,w),124)
dec %matches
}
%send The follow results matched your search:
%send $replace(%msg,|,$+($chr(32),|,$chr(32)))
}
}
else %send No matching item found
}
on *:start: {
if ($isfile(Prices.hsh)) hload Prices Prices.hsh
}
on *:exit: {
if ($hget(Prices)) hsave Prices.hsh
}
alias Updateprices {
echo -a Updating Prices - Collecting data From Price guide by Ben Goten
if ($sock(Price)) sockclose Price
if ($hget(Prices)) .hfree Prices
sockopen Price runescapecommunity.com 80
}
on *:sockopen:Price: {
sockwrite -nt $sockname GET /index.php?showtopic=136820 HTTP/1.1
sockwrite -nt $sockname HOST: runescapecommunity.com
sockwrite -t $sockname $crlf
}
on *:sockread:Price: {
var %t | sockread %t
if (*: *<br /> iswm %t) && ($chr(9) !isin %t) && (<!-- !isin %t) {
hadd -m Prices $replace($striptags($gettok(%t,1,58)),$chr(32),-) $striptags($gettok(%t,2,58))
}
elseif (Ben_Goten78 - All rights reserved 2002-2005 isin %t) {
echo -a Price Updating Complete
sockclose $sockname
}
}
alias striptags { var %x,%y = $regsub($1-,/(<[^>]+>)/g,$null,%x) | return %x }