Random "Really Bad Joke" script (BETA)

By wintergoat on Oct 20, 2011

This is a script I made, my first using sockets. You load it into remotes on your bot, and then type !rbj in your channel. It is in beta right now, and you will see why if you use it. If you have any suggestions on how to make it better, please comment.

// Random "really bad joke" script by wintergoat.
// This script is in beta for now.
// Ignore the alias at the beginning.
// Jokes are retrieved from rinkworks.com.
// Type !rbj in the channel your bot is in to use.

; alias -l htmlfree {

  ; echo TEST
  ; It's local because it won't be used by the command line, only this file.

  ; Local aliases avoid conflicting names.
  ;%exp = /(^[^<]*>|<[^>]*>|<[^>]*$)/g
  ;%x = $regsubex($1-,%exp,$null)
  ; return $1-
; }

on *:text:!rbj:#: {
  %jokebegin = 0
  %jokerequestchan = $chan
  /sockopen rbj www.rinkworks.com 80

on 1:sockopen:rbj:{
  /sockwrite -nt $sockname GET /jokes/random.cgi HTTP/1.0
  /sockwrite -nt $sockname Host: www.rinkworks.com
  /sockwrite -nt $sockname $crlf

on 1:sockread:rbj:{
  if ($sockerr) {
    echo -a Socket Error.
  else {
    var %temptext
    sockread %temptext
    echo %temptext

    if (<h2> isin %temptext) {
      %jokebegin = 1
    else if (%jokebegin == 1) {
      if (</ul> isin %temptext) {
        %jokebegin = 0
      else if (<li> isin %temptext) {
        msg %jokerequestchan $htmlfree(%temptext)
      else if (<p> isin %temptext) {
        msg %jokerequestchan $htmlfree(%temptext)


Sign in to comment.
alabama   -  Oct 23, 2011

comments should always start with a ";"

Jethro   -  Oct 20, 2011
elseif ($count(%temptext,<li>,<p>)) {
wintergoat   -  Oct 20, 2011

/me 's brain hurts...

_Dean_   -  Oct 20, 2011
echo %temptext

will return all the HTML code on status window
why did you use that?

by the way, there are some jokes with a lot of lines, and it may cause "excess flood" disconnection...

why dont you use

else if (<li> isin %temptext) || (<p> isin %temptext)  {

instead 2 elseif conditions?

i didnt understand the meaning
of set %jokebegin = 1 and then set it %jokebegin = 0

this is simple tips, and i will not mention $regex to improve your first socket

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.