here is a fast socket using the facts you have posted. I used pastebin.com to socket to as it does not go down all that often.
anyways this is just a fast mock up of a working example nothing more..
I hope this can help you in learning sockets or get a better idea about them at the lest.
as always keep coding in msl ;x
on $*:text:/^@facts$/iS:#: {
if (!$hget(f,f)) {
if ($sock(fac)) sockclose fac
sockopen fac pastebin.com 80
sockmark fac $r(1,100) msg # 11,1WTFact $chr(35)
}
}
on *:sockopen:fac: {
sockwrite -nt fac GET /RecUZJge HTTP/1.1
sockwrite -nt fac Host: $+($sock(fac).addr,$str($crlf,2))
}
on *:sockread:fac: {
var %fac | sockread %fac
if ($regex(%fac,/<div class="de\d">(.+)<\/div>/)) {
hinc -mu5 f f 1
if ($hget(f,f) = $gettok($sock(fac).mark,1,32)) {
$+($gettok($sock(fac).mark,2-,32),$hget(f,f),15,$chr(44),1) $+(",$remove($regml(1), ,"),")
sockclose fac
}
}
}
example:
<~napa182> @facts
<~Sick0> WTFact #18 "Human thighbones are stronger than concrete. "
<~napa182> @facts
<~Sick0> WTFact #34 "The human brain cannot create faces. Therefore when you dream, if you see someone you do not know, you have seen their face before. "