Summer … Except Not
Summer is supposed to be a time of uber laziness … waking up at 10 in the morning (at the earliest) and going on all sorts of random trips to random places with friends.
Alas, I have class monday through friday at 7:30 in the friggin morning … what’s up with that? :/
It’s not all bad I suppose. Right now it’s rather easy, but I guess I have my “big head” to blame (or thank?) for that, now don’t I?
I made an ircbot in php out of sheer boredom. It was actually a lot easier than I had imagined. The main file is below, the others are here.
<?php
include("config.php");
include("functions.php");
$fso = @fsockopen($host, $port, $errno, $errstr, 2) or die("can't connect\n");
if($fso) register();
while(1) {
$buffer = fgets($fso);
if(strlen($buffer) > 2){
echo "[RECV] {$buffer}";
$bad = 0;
include("commands.php");
}
else{
++$bad;
if($bad >= 2) echo "connection issue?\n";
if($bad >= 10) $restarting = TRUE;
#if we haven't heard from the server in a while, reconnect?
}
if(feof($fso) && $restarting !== TRUE) die("connection broke!\n");
if($restarting === TRUE){
sleep(1);
$fso = @fsockopen($host, $port, $errno, $errstr, 2) or die("can't connect\n");
if($fso){
register();
$restarting = FALSE;
}
}
flush();
}
?>
The semi-interesting stuff is inside the commands.php file which plays ping/pong with the server, alerts NickServ to who you are, and replies to my random commands.
Yay for boredom!
Elaine’s coming over tomorrow,
.
-josh
PS. fun convo with guy
Guy: who knows
Guy: hmm i’m going to go exercise and shower
Guy: brb
josh: at the same time?
josh: that’s nasty, i know what you’re doing in there
Guy: lol
Leave a Comment