Well I was browsing for sites and found a random thought site with over 40k entries. So naturally, I am like.. let's make a little socket for it.
I didn't put in any code to turn it on or off, or many other features other than a flood protect preventing repeated use of command. I am waiting to see if it is liked enough to spend more time on it :/
Load it in remotes, either type /randomthought to activate it yourself .. or anyone can use !rt via the text event.
Only bug I see so far is a few ppl have posted to the site obscene or blank comments.
Input, thoughts, should I spend the extra few minutes to put a channel toggle, etc, etc?
on *:TEXT:!rt*:#: { randomthought }
alias randomthought {
inc -u2 %rt.flood
if (%rt.flood > 2) { halt }
if ($sock(rt)) { sockclose rt }
sockopen rt randomthoughts.ws 80
sockmark rt #
}
on *:sockopen:rt: {
if (!%rt.idx) set %rt.idx 44000
set %rt.last $r(1,%rt.idx)
sockwrite -n rt GET /page.php?lim= $+ %rt.last HTTP/1.1 $+($crlf, HOST: randomthoughts.ws, $str($crlf,3))
}
on *:sockread:rt: {
sockread %rt | if (!%rt || $sockerr) { halt }
if ($regex(%rt, /<a href="recent_comments.php">(.*)</i)) { set %rt.idx $remove($striphtml($regml(1)),$chr(44)) }
elseif ($regex(%rt,/<h1>Random Thoughts(.*)<\/span/i)) {
msg $sock(rt).mark Random Thought of the Moment (# $+ %rt.last $+ ) : $striphtml($regml(1))
sockclose rt
}
}
;not mine, couldn't write one shorter, credit to whoever
alias -l striphtml { return $regsubex($1-, /(<(?:.+?)>)/g, $null) }
lol jasonh_000, you can't expect every person online to type with the actual, correctly spelled vocabulary. "ur" is acceptable in many quick text messages. You'll see many abbreviations used, and I'm sure you already know that if you use iphone, Blackberry, Messengers, or any type of mobile devices...etc...especially IRC chat.
Extremity, they have a webpage for mobile, which is completely random. Here is my take on using it:
on *:text:$($iif(!rt = $strip($1),$1)):*:{
if !%fc { inc -u4 %fc | $rt }
}
on *:sockopen:rt:{
tokenize 94 $sock(rt).mark
if !$sockerr {
$1 GET /gadgets/mobile/index.php HTTP/1.1
$1 Connection: close
$1 HOST: $+($sock(rt).addr,$str($crlf,2))
}
else { $3 Problem Connecting to $sock(rt).addr }
}
on *:sockclose:rt:{
tokenize 94 $sock(rt).mark
$3 Random Thought: $iif($hget(rt,3).item $hget(rt,3).data = $&
a random thought:,I'm currently thoughtless; try me again in 4 secs...,$v1)
}
alias rt {
if ($sock(rt)) sockclose rt
sockopen rt randomthoughts.ws 80
sockmark rt $+(sockwrite -nt rt,^,scon -r hadd -mu4 rt,^,$&
$+ $iif($isid,.msg $iif(#,#,$nick),echo -a))
}
on *:sockread:rt:{
if !$sockerr {
var %rt, %t /(.*)(<\/b>|<br\/>)/i
sockread %rt | if $regex(%rt,%t) {
tokenize 62 $regml(1)
$gettok($sock(rt).mark,2,94) $!remove( $* ,<b style="color:red;",<b)
}
}
else {
tokenize 94 $sock(rt).mark
$3 Problem Reading $sock(rt).addr
}
}
!rt Random Thought: Is this your life? What do you choose to make it? Sex with a random girl/guy. Drugs and alcohol on the weekends. Life is so much more.... What will you choose to make it. When will you trust God? !rt Random Thought: I'm currently thoughtless; try me again... !rt Random Thought: I wonder if when my cat runs across my face at night scratching me
I just noticed how the number of thoughts changes from page to page.
44,000 was just the initial number. The socket updates the rt.idx which is the $r value after the socket runs once. But you are right Jethro, I am grabbing the wrong number. I will update to set the initial $r to 40,000 and have the sockread fetch the number of thoughts and not the number of comments.