my $sock = IO::Socket::INET->new( Proto=>"$config->{protocol}", PeerAddr=>"$config->{server}", PeerPort=>"$config->{port}", ) or die "Cannot Connect to Server"; $sock->send("NICK $config->{nick}\n"); $sock->send("USER " . $config->{ident} x 3 . ":$config->{ircname}\n"); $sock->autoflush(1); my %userAuthenticatedList; # Authenticated Users and Hosts my %channels; # Stored List of channels kicked from my $connected; # Prevent constant "log-on" of Bot my $salt = $config->{salt}; # md5 key for encryption my $incomingMessage; # Handle incoming signals/events from server. while (1) { $sock->recv($incomingMessage, 1024); if ($incomingMessage=~/PING :(.*)/i) { $sock->send("PONG :$1\n"); &on_connect_join() if (!$connected); # The portion determines if the channel is # is a valid entry in the channels channels # hash/array before joining the channel. foreach (keys %channels) { &join_chan($_) if ($channels{$_}); } } # Syntax from server is as follows # :NickName!User@host PRIVMSG (individual/#channel) :text if ($incomingMessage=~/:(.*)!(.*)@(.*) PRIVMSG (.*) :$config->{CMDCHAR}(.*)/i) { my $userName = "$1"; my $userHost = $1 . "!" . $2 . "@" . $3; $_ = "$5"; my @args = split " ", $_; my $commands = shift(@args); my $args = "@args"; print "Someting was received\n"; print "$userName $userHost : $commands $args\n"; if ($commands eq "identify") { # Check for command being called. $args = md5_base64($args, $salt); print "Sent to userLogin\n" if userLogin($userName, $userHost, $args); } elsif ($userHost eq $userAuthenticatedList{$userName}) { for (my $i=0; $pFuncsA[$i]->{command}; $i++) { if ($pFuncsA[$i]->{command} eq $commands) { $pFuncsA[$i]->{func}($args); } } } }