Random Jokes Plus Facts

Platform:  mIRC
Published  Jul 05, 2012
Updated  Jul 05, 2012
This work below is yet another forum request that I've decided to submit as a part of my snippet collection. For those who find this snippet useful, It's for the bot client, and the trigger is either !facts, @facts, .facts or !jokes, @jokes, .jokes. on $*:text:/^[!@.](fact|joke)s$/iS:#:{
if (!%f) {
inc -u3 %f
var %s = $+(rjf,$str($ticks,2),$site)
if ($sock(%s)) sockclose $v1
sockopen %s www.randomfunfacts.com 80
sockmark %s .msg # $regml(1)
}
}
on *:sockclose:rjf*:{
tokenize 32 $sock($sockname).mark
var %s = $+(rjf,$str($ticks,2),$site)
if ($sock(%s)) sockclose $v1
sockopen %s www.jokesclean.com 80
sockmark %s $1-2
}
on *:sockopen:rjf*:{
tokenize 32 $sock($sockname).mark
if ($sockerr) {
$1-2 Error: Connection Issue...
sockclose $sockname
}
else {
if ($3 == fact) {
var %rjf = sockwrite -nt $sockname
%rjf GET / HTTP/1.1
%rjf Connection: close
%rjf Host: $+($sock($sockname).addr,$str($crlf,2))
}
else {
var %rjf = sockwrite -nt $sockname
%rjf GET /OneLiner/Random/ HTTP/1.0
%rjf Host: $+($sock($sockname).addr,$str($crlf,2))
}
}
}
on *:sockread:rjf*:{
tokenize 32 $sock($sockname).mark
if ($sockerr) {
$1-2 Error: Issues in Reading...
sockclose $sockname
halt
}
goto $iif($3 == fact,fact,joke)
:fact
sockread &rjf
var %info = $regsubex($bvar(&rjf,1-).text,/<[^>]*>|\t$&
$+ RLOpenInNewWindow|"1";|var RLRepeatKeywords/g,$chr(32))
if ($gettok($replace(%info,&nbsp;,$chr(94)),2,94)) {
$1-2 $remove($gettok($v1,11-,32),24c6)
sockclose $sockname | halt
:joke
var %jokes
sockread %jokes
if ($regex(%jokes,/(.*)<\/font><\/p>/)) {
$sock($sockname).mark $replace($gettok($regml(1),3-,62),&nbsp;,$chr(32))
sockclose $sockname
}
halt
}
}

Comments

Sign in to comment.
Dani_l11   -  Nov 26, 2012
$str($ticks,2)

Why? Isn't $ticks as much random as $str($ticks,2)
$r(0,9) is as much random as $str($r(0,9),2) or am I missing something"?

Klim:
Edit the first line to
on $*:text:/^[!@.](fact)s$/iS:#:{
 Respond  
WorldDMT   -  Nov 22, 2012
hehehe busy :p
 Respond  
Jethro   -  Nov 21, 2012
Thank you, WorldDMT. Wait a minute...where have you been all my life? :p
 Respond  
WorldDMT   -  Nov 19, 2012
nice job dude ;)
 Respond  
Jethro   -  Jul 15, 2012
Kilim, the jokes command is to trigger the joke part of the script. By removing it, the script will cease to send a random line of joke.
 Respond  
Kilim   -  Jul 15, 2012
Excellent Jethro. Is there anyway to remove the !jokes command from this though? I tried going through the code myself but your code is a little too advanced for me to go through editing. If not, anyway thanks for the great script!
 Respond  
blackvenomm666   -  Jul 09, 2012
+like looks good jeth
 Respond  
Jethro   -  Jul 08, 2012
Much obliged!
 Respond  
toclafane1   -  Jul 08, 2012
Liked your comment and your Snippet. :)
 Respond  
Jethro   -  Jul 07, 2012
Thank you. Please give me a like for the support of my work.
 Respond  
toclafane1   -  Jul 07, 2012
Great Snippet Jethro. Very useful (for me) :P
 Respond  
RIcko   -  Jul 05, 2012
thanks for bringing this into public, no same results anymore :P
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.