Old stuff/Perl/newirc/old_bot.pl
(Deskargatu)
#!/usr/bin/perl -w
use Errno qw(EAGAIN);
use strict;
use IO::Socket::INET;
use Ircvar;
my ($pid,$clavier);
$clavier = 'x';
foreach(split(" ",$fichiers_a_charger))
{
print "$_\t";
do "$_" or die("[ERREUR]$_ $!");
print "[OK]\n";
}
while ($clavier ne 'quit')
{
print "\n\n";
print "Tentative de connection: ";
my $sock = IO::Socket::INET->new(
PeerAddr => "$server",
PeerPort => $port,
Proto => 'tcp' )
or die("Connection echouee");
print "OK\n";
select $sock;
while (<$sock>)
{
if ($pid = fork)
{
$clavier = <STDIN>;
print $clavier;
}
elsif (defined $pid)
{
print STDOUT "$_";
SWITCH:
{
/^(?::[^\s]+ )?NOTICE AUTH :.* Checking Ident/i && do { register_irc; last SWITCH; };
/^PING :(.*)/i && do { print "PONG $1"; print STDOUT "Sending:\tPONG\n"; last SWITCH; };
/^:[^\s]+ 376/ && do { join_chan; last SWITCH; };
/^:[^\s]+ 353 $bot_nick = $chan :(.*)\r/ && do { new_join($1); last SWITCH; };
/:[^\s]+ (?:NICK|QUIT|PART|JOIN|KICK)/i && do { nickchange($_); last SWITCH;};
/:[^\s]+ KICK $chan $bot_nick :/ && do { join_chan; last SWITCH;};
/:([^!]+)[^\s]+ PRIVMSG (?:$chan|[^\s]+) :(\@.*)\r/ && do {
foncts($chan,$fullpower,$1,$2); last SWITCH;};
}
}
}
}
print "\n\n\nConnection close\n\n";