This is my first non parser socket, feel free to post on how i can make my scripts better in the future
add this to aliases /nohtml return $replace($remove($regsubex($regsubex($1-,/<[^>]+>/g,$null),/&#(\d+);/g,$chr(\1)),$chr(9)), ,$chr(32),©,$chr(169),",",',',',',<,<,>,>,&,&,',',$eval(%27,0),',–,$chr(150),",",% $+ 2C,$chr(44))
~Mfoust~
on $*:TEXT:/^[!@.]players\b/i:#: {
if ($sock(rsplayers)) { sockclose rsplayers } {
set %msg $iif(@* iswm $1 ,msg $chan,notice $nick )
/sockopen rsplayers www.RuneScape.com 80
}
}
on *:SOCKOPEN:rsplayers: {
/sockwrite -nt $sockname get /title.ws HTTP/1.1
/sockwrite -nt $sockname Host: www.runescape.com
/sockwrite -nt $sockname $crlf
}
on *:SOCKREAD:rsplayers:{
if ($sockerr) { sockclose $sockname | halt }
var %sockreader | sockread %sockreader
if (*<span id="playerCount">* people currently online</span>* iswm %sockreader) {
tokenize 32 %sockreader
%msg There are $nohtml($1-2) people currently online.
unset %msg | sockclose $sockname
}
}
Good to see you expanding to sockets Mfoust. As per personal preference $regex works well in conjunction with GET sockets, and might be something look into someday if the need arises. Also if you have an alias that is required for it to work, it might be a good idea to paste it in along with the snippet and not in the description itself.
You don't need nohtml alias with regex:
on $*:text:/^([!@.])players$/iS:#:{
if (!%f) { inc -u4 %f | if ($sock(rsplayers)) { sockclose $v1 }
sockopen rsplayers www.RuneScape.com 80
sockmark rsplayers $iif(@ == $regml(1),msg #,notice $nick)
}
}
on *:SOCKOPEN:rsplayers: {
sockwrite -nt $sockname GET /title.ws HTTP/1.1
sockwrite -nt $sockname Host: www.runescape.com
sockwrite -nt $sockname
}
on *:SOCKREAD:rsplayers:{
if ($sockerr) { sockclose $sockname | halt }
var %sockreader | sockread %sockreader
if ($regex(%sockreader,/(\d+,\d+\s)/)) {
$sock($sockname).mark There are $regml(1) people currently online.
sockclose $sockname
}
}