The Official Wetfish Robot

Put this in your remotes tab in mIRC, it makes requests to a PHP file and listens for commands. Change irc.wetfish.net to your subdomain and dongbrain.php to whatever file you want to use to control the bot. If you're not interested in making a bot, but still want to contribute, you can use this script too!! In doing so you essentially keep a record of the activity in whatever channels you visit, which can later be parsed for images, videos, or statistics in general.

alias urlencode {
  var %text = $1-
  var %newtext
  var %i = 1, %e = $len(%text)
  while (%i <= %e) {
    var %a = $asc($mid(%text,%i,1))
    if (%a == 32) {
      var %newtext = $+(%newtext,+)
    }
    elseif ((%a isnum 97-122) || (%a isnum 65-90) || (%a isnum 48-57) || ($istok(45 95 46 33 42 39 40 41,%a,32))) {
      var %newtext = $+(%newtext,$chr(%a))
    }
    else,
    var %newtext = $+(%newtext,$chr(37),$base(%a,10,16,2))
   
    inc %i
  }
  return %newtext
}

on *:text:*:#: {
  set %server $urlencode($server)
  set %nick $urlencode($nick)
  set %channel $urlencode($chan)
  set %message $urlencode($1-)
  set %count 1

  hmake commands
  sockopen dong- $+ $rand(1, 999999) irc.wetfish.net 80 
}
on *:sockopen:dong*{
  sockwrite -n $sockname GET /dongbrain.php?server= $+ %server $+ &nick= $+ %nick $+ &channel= $+ %channel $+ &message= $+ %message HTTP/1.1
  sockwrite -n $sockname Host: irc.wetfish.net
  sockwrite -n $sockname Vary: Accept-Encoding
  sockwrite -n $sockname Connection: close
  sockwrite -n $sockname Content-Type: text/html
  sockwrite -n $sockname X-Pad: avoid browser bug
  sockwrite -n $sockname $crlf

  unset %message
}

on *:sockread:dong*{
  sockread %data
  hadd commands %count %data
  inc %count
}

on *:sockclose:dong*{
  var %loop = 1

  while (%loop <= %count) {
    docommands $hget(commands, %loop)
    inc %loop
  }

  hfree commands
  unset %count
  unset %loop
}

alias docommands {
  if ($1 == notice) {
    notice $2-
  }
  elseif ($1 == msg) {
    msg $2-
  }
  elseif ($1 == echo) {
    echo $2-
  }
  else,
   ; unhandled command

}

Tags: Projects | Old News | Programming | IRC | mIRC