on $*:TEXT:/^[!@.]item/Si:#:{
if (!$2) {
notice $nick 12[4 Item 12]: You must supply a item keywork to lookup
}
else {
inc %n
set $+(%,tip.item.,%n) $replace($2-,$chr(32),+)
set $+(%,tip.style.,%n) $iif($left($1,1) == @,msg $chan,notice $nick) 12[4 Item 12]:
set $+(%,tip.nick.,%n) $nick
sockopen $+(tip.,%n) tip.it 80
}
}
on *:SOCKOPEN:tip.*:{
var %id = $gettok($sockname,2,46)
sockwrite -n $sockname GET /runescape/index.php?rs2item=&orderby=0&keywords= $+ $($+(%,tip.item.,%id),2) $+ &Players=all&category=0&subcategory=0&cmd=8&action=Manage_Items&search=1 HTTP/1.1
sockwrite -n $sockname Host: tip.it
sockwrite -n $sockname $+($crlf,$crlf)
}
on *:SOCKREAD:tip.*:{
var %id = $gettok($sockname,2,46)
var %nick = $($+(%,tip.nick.,%id),2)
var %item = $replace($($+(%,tip.item.,%id),2),+,$chr(32))
var %style = $($+(%,tip.style.,%id),2)
if ($sockerr) {
%style An error occured while connecting
unset $+(%,tip.*)
sockclose $+(tip.,%id)
}
else {
var %read
sockread %read
if (*No items matched your search* iswm %read) {
%style No results were found for " $+ %item $+ "
unset $+(%,tip.*)
sockclose $+(tip.,%id)
}
if ($regex(%read,/
(.*) | /Si)) {
set $+(%,tip.name.,%id) $regml(2)
set $+(%,tip.link.,%id) $regml(1)
sockopen $+(item.,%id) tip.it 80
sockclose $+(tip.,%id)
}
}
}
on *:SOCKOPEN:item.*:{
var %id = $gettok($sockname,2,46)
sockwrite -n $sockname GET /runescape/ $+ $($+(%,tip.link.,%id),2)
sockwrite -n $sockname Host: tip.it
sockwrite -n $sockname $+($crlf,$crlf)
}
on *:SOCKREAD:item.*:{
var %id = $gettok($sockname,2,46)
var %nick = $($+(%,tip.nick.,%id),2)
var %item = $replace($($+(%,tip.item.,%id),2),+,$chr(32))
var %style = $($+(%,tip.style.,%id),2)
if ($sockerr) {
%style An error occured while connecting
unset $+(%,tip.*)
sockclose $+(item.,%id)
}
else {
var %read
sockread %read
if (*Members?** iswm %read) {
tokenize 32 $nohtml(%read)
set $+(%,tip.members.,%id) $remove($1-,Members?,$chr(6),$chr(32))
}
if (*Quest?** iswm %read) {
tokenize 32 $nohtml(%read)
set $+(%,tip.quest.,%id) $remove($1-,Quest?,$chr(6),$chr(32))
}
if (*Tradeable?** iswm %read) {
tokenize 32 $nohtml(%read)
set $+(%,tip.trade.,%id) $remove($1-,Tradeable?,$chr(6),$chr(32))
}
if ($($+(%,tip.found.note.,%id),2)) {
inc $+(%,tip.time7.,%id)
if ($($+(%,tip.time7.,%id),2) == 2) {
tokenize 32 $nohtml(%read)
set $+(%,tip.note.,%id) $remove($1-,$chr(6))
unset $+(%,tip.found.note.,%id)
}
}
if ($($+(%,tip.found.use.,%id),2)) {
inc $+(%,tip.time6.,%id)
if ($($+(%,tip.time6.,%id),2) == 2) {
tokenize 32 $nohtml(%read)
set $+(%,tip.use.,%id) $remove($1-,$chr(6))
unset $+(%,tip.found.use.,%id)
}
}
if ($($+(%,tip.found.loc.,%id),2)) {
inc $+(%,tip.time5.,%id)
if ($($+(%,tip.time5.,%id),2) == 2) {
tokenize 32 $nohtml(%read)
set $+(%,tip.loc.,%id) $remove($1-,$chr(6))
unset $+(%,tip.found.loc.,%id)
}
}
if ($($+(%,tip.found.lalch.,%id),2)) {
inc $+(%,tip.time4.,%id)
if ($($+(%,tip.time4.,%id),2) == 2) {
tokenize 32 $nohtml(%read)
set $+(%,tip.lalch.,%id) $remove($1-,$chr(6))
unset $+(%,tip.found.lalch.,%id)
}
}
if ($($+(%,tip.found.gen.,%id),2)) {
inc $+(%,tip.time3.,%id)
if ($($+(%,tip.time3.,%id),2) == 2) {
tokenize 32 $nohtml(%read)
set $+(%,tip.gen.,%id) $remove($1-,$chr(6))
unset $+(%,tip.found.gen.,%id)
}
}
if ($($+(%,tip.found.halch.,%id),2)) {
inc $+(%,tip.time1.,%id)
if ($($+(%,tip.time1.,%id),2) == 2) {
tokenize 32 $nohtml(%read)
set $+(%,tip.halch.,%id) $remove($1-,$chr(6))
unset $+(%,tip.found.halch.,%id)
}
}
if ($($+(%,tip.found.cat.,%id),2)) {
inc $+(%,tip.time.,%id)
if ($($+(%,tip.time.,%id),2) == 3) {
tokenize 32 $nohtml(%read)
set $+(%,tip.cat.,%id) $remove($1-,$chr(6))
unset $+(%,tip.found.cat.,%id)
}
}
if ($($+(%,tip.found.ex.,%id),2) && !$($+(%,tip.examine.,%id),2)) {
tokenize 32 $nohtml(%read)
set $+(%,tip.examine.,%id) $remove($1-,$chr(6))
unset $+(%,tip.found.ex.,%id)
}
if ($($+(%,tip.found.spec.,%id),2)) {
inc $+(%,tip.times2.,%id)
if ($($+(%,tip.times2.,%id),2) == 2) {
tokenize 32 $nohtml(%read)
set $+(%,tip.spec.,%id) $remove($1-,$chr(6))
}
}
if (* Examine:* iswm %read) {
set $+(%,tip.found.ex.,%id) true
}
if (*Category* iswm %read) {
set $+(%,tip.found.cat.,%id) true
}
if (* | * iswm %read) {
set $+(%,tip.found.halch.,%id) true
}
if (** iswm %read) {
set $+(%,tip.found.spec.,%id) true
}
if (** iswm %read) {
set $+(%,tip.found.gen.,%id) true
}
if (** iswm %read) {
set $+(%,tip.found.lalch.,%id) true
}
if (** iswm %read) {
set $+(%,tip.found.loc.,%id) true
}
if (** iswm %read) {
set $+(%,tip.found.use.,%id) true
}
if (** iswm %read) {
set $+(%,tip.found.note.,%id) true
}
if (** iswm %read) {
%style Item: $($+(%,tip.name.,%id),2) URL: http://tip.it/runescape/ $+ $($+(%,tip.link.,%id),2)
%style Members? $rem.bt($($+(%,tip.members.,%id),2)) Tradable? $rem.bt($($+(%,tip.trade.,%id),2)) Quest? $rem.bt($($+(%,tip.quest.,%id),2))
%style High Alch: $rem.ft($($+(%,tip.halch.,%id),2)) Low Alch: $rem.ft($($+(%,tip.lalch.,%id),2)) Location: $rem.bt($($+(%,tip.loc.,%id),2)) Uses: $rem.bt($($+(%,tip.use.,%id),2)) General Sells: $rem.ft($($+(%,tip.gen.,%id),2))
%style Examine: $rem.b4($($+(%,tip.examine.,%id),2)) Category: $rem.bt($($+(%,tip.cat.,%id),2)) Specialty Shop Sells: $rem.ft($($+(%,tip.spec.,%id),2)) Notes: $rem.bt($($+(%,tip.note.,%id),2))
unset $+(%,tip.*)
sockclose $+(item.,%id)
}
}
}
alias -l rem.b4 {
var %x = $remove($1-,$right($1-,3),$left($1-,4))
var %x = $remove(%x,$left(%x,1))
return %x
}
alias -l rem.bt {
var %x = $remove($1-,$right($1-,3),$left($1-,3))
return %x
}
alias -l rem.ft {
var %x = $remove($1-,$left($1-,3))
return %x
}
alias nohtml {
var %x,%i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x)
%x = $replace(%x, ,$null)
return %x