Random Chuck Norris Fact/Joke

By blackvenomm666 on Jun 10, 2011

Put it into a NEW remotes file either on your script or a bots if on a bots the command is @nfact if on your personal script is /nfact will randomly post a chuck norris joke/fact

on *:text:*:#: {
tokenize 32 $strip($1-)
  if ($1 == @nfact) {
    .var %nfactchan $chan
    sockopen nfact www.chucknorrisjokes.linkpress.info 80
  }
}
alias nfact {
  var %nfactchan $chan
  sockopen nfact www.chucknorrisjokes.linkpress.info 80
}
on *:sockopen:nfact: {
  sockwrite -n $sockname GET /random-fact.php HTTP/1.1
  sockwrite -n $sockname Host: $+($sock(nfact).addr,$str($crlf,2))
}
on *:sockread:nfact: {
  var %nfact | sockread %nfact
  if ($regex(%nfact,/<p style="font-size: 2.5em;">(.+)(Norris.+)<\/p>/)) {
    msg %nfactchan $regml(1) $regml(2)
    sockclose nfact
  }

}

Comments

Sign in to comment.
Jethro   -  Jun 12, 2011

What is your alternative snippet, Sharky_Dude?

 Respond  
Sharky_Dude   -  Jun 12, 2011

All this over a chuck norris socket?
Thanks Ryan for all the help with my alternate snippet.

 Respond  
Jethro   -  Jun 12, 2011

Yes, that's a smart, witty sock error reply, isn't it? :P I think I made a socket alternative to someone's random thought socket script, and I had it made, "I'm currently thoughtless; please try me again in 4 seconds" if no thoughts are found. lol And that corresponds to the trigger flood control time limit, too.

 Respond  
blackvenomm666   -  Jun 12, 2011

hahaha that would be funny

 Respond  
napa182   -  Jun 12, 2011

Jethro_, to me that does kind of defeat the purpose of using a socket, but to others it may not. If the site does go down One could always have it say "Due to Chuck Norris finding this site we are currently hiding at the moment, but we hope to be back soon." as the sockerr message.

 Respond  
Jethro   -  Jun 11, 2011

If you make a socket script to gather info from a website and have it jotted down in a text file, doesn't that defeat the purpose of using socket in the first place? ;\

I understand the odds of a website being down, but that's not really a frequent matter...what matters is the website source code being altered, which could happen every once in a while.

 Respond  
blackvenomm666   -  Jun 11, 2011

i havent gotten into the sockerr part of sockets yet haha. im finding them hard to learn for the most part. napa has been very patient with my questions when i have em

 Respond  
Grant-   -  Jun 11, 2011

I like it, one addition you can add is write all the new messages to a file, and then whenever there's a sockerr, you can just read from that file.

 Respond  
Jethro   -  Jun 11, 2011

Well, actually when you use an alias, think of it as a call girl, all you have to do is dial her up and she'll be there for you. lol

 Respond  
blackvenomm666   -  Jun 11, 2011

its so you can use /alias i didnt even think of doing it how napa did it

 Respond  
Jethro   -  Jun 11, 2011

Why do you open the socket twice, blackvenommm666? lol

One of these days I wish to see some "unconventional" socket methods if there's one...

 Respond  
napa182   -  Jun 10, 2011

lol @ you using the trigger @nfact
anyways you are getting better at sockets.. ;x
you may want to add in ur description to add this to it's own remote an leave it by it's self, cuz of the way you have ur trigger ie:

on *:text:*:#: {

it will make what ever is in there not work
one more thing if you have my random nick fact socket on a bot that has this in it, it will conflict with it.
Thats cuz the trigger and socket name for that is also called nfact

you should add a bit of flood protect to it as well use sockmark
here is an example:

on $*:text:/^@nfact$/iS:#:nfact
alias nfact {
  if (!%f) { inc -u4 %f
    sockopen nfact www.chucknorrisjokes.linkpress.info 80
    sockmark nfact msg # 12,1 
  }
}
on *:sockopen:nfact: {
  sockwrite -n nfact GET /random-fact.php HTTP/1.1
  sockwrite -n nfact Host: $+($sock(nfact).addr,$str($crlf,2))
}
on *:sockread:nfact: {
  var %nfact | sockread %nfact
  if ($regex(%nfact,/\t{3}<p style.+>(.+?)<\/p>/)) {
    $sock(nfact).mark $regml(1) 
    sockclose nfact
  }
}

5/10 +Like

 Respond  
Sharky_Dude   -  Jun 10, 2011

O.0 wtf is wrong with you? ~dies~ okay so I'm rating your work. 10 for a good socket -1000000000000 for it being fkn chuck norris

 Respond  
blackvenomm666   -  Jun 10, 2011

:)

 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.