Random fact
Platform: mIRC
Published Oct 06, 2008
Updated Oct 06, 2008
This, quite simply, pulls a random fact from
www.randomfunfacts.com and displays it to the active channel. Load this into your remotes and type /fact to make it work.
Go uselessness!
alias fact {
if ($sock(fact)) { sockclose fact }
sockopen fact www.randomfunfacts.com 80
}
on *:sockopen:fact: {
if ($sockerr) {
echo -a * There was a problem connecting to the website. Please try again.
sockclose fact
}
else {
sockwrite -n $sockname GET / HTTP/1.0
sockwrite -n $sockname Host: www.randomfunfacts.com $+ $crlf $+ $crlf
}
}
on *:sockread:fact: {
if ($sockerr) {
echo -a * There was a problem retrieving data from the website. Please try again.
sockclose fact
}
else {
sockread %fakt
if (<font face="Verdana" size="4"><strong><i> isin $remove(%fakt,$chr(9))) {
set %fact $left($htmlfree(%fakt),-6)
}
}
}
on *:sockclose:fact: {
if (%fact) { msg $active %fact }
unset %fakt %fact
}
alias htmlfree { return $regsubex($$1-,/^[^<]*>|<[^>]*>|<[^>]*$/g,) }