#!/usr/bin/perl
#--------------------------------------------------#
# IRC(InterNet Relay Chat) bot framework #
#--------------------------------------------------#
#----------------------Coded By--------------------#
# _|_|_| _|_|_|_|_| _| _| #
# _| _| _|_|_| _| _|_|_| _| _| #
# _|_|_| _| _| _| _| _|_|_|_| #
# _| _| _| _| _| _| _| #
# _| _|_|_| _| _|_|_| _| _| #
#--------------------------------------------------#
# Important Notice Below, Please Read... #
# ====================================== #
# 1) The Terms and Conditions to this program are #
# located at the bottom of the code, along with #
# all the things stated here. #
# #
# 2) You may modify this source to fit your needs. #
# It may be modified in any shape, or form... #
# #
# 3) You may sell this source to people in both #
# physical, and digital forms. #
# #
# 4) This source IS owned by the original creator #
# PaTcH, and by my/his wishes, please leave this #
# and all the above (Including the ASCII) in this #
# programs source code. #
#--------------------------------------------------#
#-------Please Read Notice At End Of Source--------#
#--------------------------------------------------#
use IO::Socket;
use Digest::MD5 qw(md5_hex);
my $system = system(clear);
if($system = -1) { system(cls); } else { system(clear); }
# Declaration of the Variables..
my ($oNICK, $NICK, $SERVER, $IDEN, $SOCKET, $PINGED);
$oNICK=$ARGV[0] if $ARGV[0] || &argerror;
$NICK=$ARGV[1] if $ARGV[1];
$SERVER=$ARGV[2] if $ARGV[2];
$SOCKET=new IO::Socket::INET(
PeerAddr => $SERVER,
PeerPort => 6667,
Proto => 'tcp') or
die "Could not open socket to $SERVER\n";
if($SOCKET) {
print("-> You're Now Connected To : $SERVER\n");
print("-> Please do a /msg $NICK !join <channel>\n");
}
$SOCKET->send("USER $NICK $NICK $NICK $NICK $NICK\r\n");
$SOCKET->send("NICK $NICK\r\n");
while(my $input = <$SOCKET>) {
$input =~ s/\r\n//;
if(!$PINGED) {
sleep(1);
$PINGED=1;
}
if($input =~ /^PING (\S+)$/i) {
$SOCKET->send("PONG $1\r\n");
}
#--------------------------#
# We'll Start The CMDs Now #
#--------------------------#
if($input =~ /^:$oNICK!\S+ PRIVMSG (\S+) :!join (\S+)$/i) {
print("-> Joining The Channel $2 | Command From $1\r\n");
$SOCKET->send("JOIN $2\r\n");
}
if($input =~ /^:$oNICK!\S+ PRIVMSG (\S+) :!speak (.*)$/i) {
print("-> Speaking the words '$2' to $1\r\n");
$SOCKET->send("PRIVMSG $1 $2\r\n");
}
if($input =~ /^:$oNICK!\S+ PRIVMSG (\S+) :!quit$/i) {
print("-> Quiting\!\n");
$SOCKET->send("QUIT\r\n");
}
#--------------------------#
# MD5 Logger #
#--------------------------#
if($input =~ /^:(\S+)!\S+ PRIVMSG (\S+) :(.*)$/i)
{
my (@test,$array_num,$reg_md5);
@test = split(/ /,$3);
$array_num=@test;
for(my $i=0;$i<$array_num;$i++)
{
my $shifter = shift(@test);
my $string = "$shifter:" . md5_hex($shifter) . "\n";
my $found = 0;
open(MD5LOGRD,"<","LOGMd5.log") || die "Failed! : $!\n";
while(my $q = <MD5LOGRD>)
{
if($q eq $string) { $found++ }
}
close(MD5LOGRD);
if(!$found)
{
open(MD5LOG, ">>", "LOGMd5.log") or die "Failed $!\n";
print MD5LOG $string;
close(MD5LOG);
}
}
}
}
#------------#
# Sub Functs #
#------------#
sub argerror {
if($system = -1) { system(cls); } else { system(clear); }
if(!$ARGV[0]) {
print("\n-> You've forgotten your argument(s),\n");
print("-> which should be the owners' nick, botnick, and server.\n");
print("-> in that order...\n\n");
}
}
#--------------------------------------------------------------------------------#
# 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 program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #
#--------------------------------------------------------------------------------#
# PaTcH (Robert S) Copyright (C) 2006-2008