#!/usr/bin/perl # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This script is made by "bluesceada" # Look at http://www.gnu.org/licenses/gpl.txt my $version ='very early without a version number'; my $server = "irc.freenode.net"; my $port = '6667'; my $nick = "MahubaPBot"; my @channels = ("#genbox", "#tryout"); my $check; my $temp = 0; my @split; my $count; use IO::Socket; use Time::HiRes qw(usleep); use strict; print "Perl Bot for IRC - Version: ".$version."\n"; usleep 750000; print "Connecting...\n\n"; my $remote = IO::Socket::INET->new(Proto => "tcp",PeerAddr => $server,PeerPort => $port) || die "cannot connect to $server - port $port\n"; $remote->autoflush(1); $remote->send ("USER pbot pebot pelbot :bot\n"); $remote->send ("NICK ".$nick."\n"); while ($remote->connected) { # check and print the stuff from the server $check = " "; $check = <$remote>; print $check; # NICK Block (Error 433 or 431) if ($check =~ m/\s(.*)(433|431)\s(.*)/ ) { $nick = $nick."_"; $remote->send ("NICK ".$nick."\n"); print ("NICK ".$nick."\n"); } # Autojoin $count = @channels; while ($count > $temp) { $temp++; $remote->send ("JOIN ".$channels[$temp-1]."\n"); } # PING PONG Block @split = split(/:/, $check); if ($split[0] eq "PING ") { print $remote ("PONG :".$split[1]."\n"); print ("PONG :".$split[1]); } # wait a bit usleep 175000; } if (!$remote->connected) { die "ERROR - connection by ".$server."\n"; } # never get here i'd tell o.O $remote->send ("QUIT See you\n"); $remote->shutdown; exit 1;