alias tib.s {
sockclose Tibia
sockopen Tibia www.tibia.4players.de 80
; http://tibia.4players.de/community/?subtopic=character&name=Rott
if ($1-) {
.sockmark Tibia $+(/community/?subtopic=character&name=,$1-)
}
}
on *:sockopen:Tibia:{
if ($sockerr) {
echo $color(info) -s *** Socket Error (on open) \ $sockname - $sock($sockname).ip
return
}
sockwrite -n $sockname GET $sock($sockname).mark HTTP/1.1
sockwrite -n $sockname Host: www.tibia.4players.de
sockwrite -n $sockname Accept: */*
sockwrite $sockname $crlf
}
on *:sockread:Tibia:{
if ($sockerr) {
echo $color(info) -s *** Socket Error (on read) \ $sockname - $sock($sockname).ip
return
}
var %tmp
sockread -fn %tmp
if (doesn't exist. isin %tmp) $&
echo -s This character doesnt exist
elseif (Character Information isin %tmp) {
tokenize 32 $CharData($RemoveHTML(%tmp))
var -s %Name = $1 | ; Save the name
var -s %Sex = $2 | ; Save the gender
var -s %Profession = $3 | ; Save the profession
var -s %Level = $4 | ; Save the level
var -s %World = $5 | ; Save the world
var -s %Residence = $6 | ; Save the residence
;
; Presumably, you'd want to pass the values to another alias or write them somewhere.
; You'd do that here.
;
}
}
alias RemoveHTML {
var %a
!.echo -q $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,,%a)
return %a
}
alias CharData {
var %a
!.echo -q $regsub($1-, /(^Character informationName:|Sex:|Profession:|Level:|World:|Residence:|Last login$)/g, $chr(32), %a)
return %a
}