Tfe

Ongi etorri tfe-ren webgunera...

Old stuff/Perl/newirc/bot.pl

(Deskargatu)
#!/usr/bin/perl -w


use Errno qw(EAGAIN);
use strict;
use IO::Socket::INET;
use Ircvar;

$|++;
my $home = $ENV{'HOME'};
my @fichiers;


my ($pid,$clavier);
$clavier = 'set';

foreach(split(" ",$fichiers_a_charger))
{
print "$_\t";
do "$_" or die("[ERREUR]$_ $!");
print "[OK]\n";
}


$SIG{'USR1'} = \&paste;
sub paste
{
    opendir(DIR,"$home/.bot/New");
    @fichiers = grep(! /^\./,readdir(DIR));
    close DIR;
    print "privmsg $chan :Nouveau Paste recu: http://les-bonbons.homelinux.com/../blabla/$fichiers[0]\n";
    unlink("$home/.bot/News/$fichiers[0]\n");
}
		




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>)
    {

#    	print STDOUT "$_";
    
    	
	SWITCH:
	{
		/^(?::[^\s]+ )?NOTICE AUTH :.* Checking Ident/i  && do { register_irc; last SWITCH;  };

		/^PING :(.*)/i && do { print "PONG $1\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); };
		
		
   	        /:([^!]+)[^\s]+ PRIVMSG (?:$chan|[^\s]+) :(.*)\r/ && do { 
	        print STDOUT "<$1>$2\n";
		
		&grabber($_);
		}
	

    }    

}

print "\n\n\nConnection close\n\n";