I noticed an error for channel in my last code + I added a check to see if the user exists before displaying any data. Added small explanations
alias statx { .remove statx.txt | sockclose statx | sockopen statx realm.worldofchris.org 80 }
;Removed any instances of statx.txt "temp" file, used socket to connect to site
alias statxa {
noop $read(statx.txt,w,$+(*,%stx,*))
; creates no operations for the $read command since I just need the location number
if ($readn > 0) {
; Checks to see if my $read came out with something if it didnt then it skips to else
%y = $readn
; var created to store the numerical value of $read
msg %stx.a StatX> %stx RACE $statxb(1) CLASS $statxb(2) GENDER $statxb(3) PVPRANK $statxb(4) LEVEL $statxb(5) MAP $statxb(6) AREAID $statxb(7) XPOS $statxb(8) YPOS $statxb(9) ONTIME $statxb(10) LATENCY $statxb(11)
; msg displayed use with the alias statxb that was created }
else { msg %stx.a Sorry %stx is not currently online or a valid entry }
; Now again if $readn returns nothing it will display this message to the channel}
alias statxb { return $read(statx.txt,$calc(%y + $1)) }
; instead of writting the command many times I made it shorter by making an alias
on 1:sockopen:statx:{
;once sock is open perform these commands
.sockwrite -n statx GET /stats.xml HTTP/1.1
; first we need the path of the file we want "/stats.xml" .sockwrite -n statx HOST: realm.worldofchris.org
; second we have to give the hostname back which is the site
.sockwrite -n statx $crlf
; We need a line break to properly dump the data}
on 1:sockread:statx:{
; Socket reads data if properly handled in sockopen event
if ($sockerr > 0) return
; if error occurs return meaning go to next or stop
var %x | sockread -fn %x
; here we create a temporary var that the data will go to has well is read the data into the var
write statx.txt $remove($regsubex(%x,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,),$chr(9))
; If all is ok this writes to statx.txt without the HTML tags so I can search whatever I need
}
on *:TEXT:!statx*:#:{
; Initiates if !statx DATA is said in channel
if ($$2) {
; Checks to see if there is DATA typed after the command !statx before continuing
statx
; Here it calls the statx alias on top to dump the site
%stx = $$2 | %stx.a = # | .timerstat 1 3 /statxa
; Here I temporarly stores the DATA entered and channel into 2 vars and
; made a timer to start the actual check to see if someone is in the list in 3 seconds
}
}