Tfe

Ongi etorri tfe-ren webgunera...

Old stuff/Perl/droyer_irc/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 sur $server : ";
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;  };
		/^(?::[^\s]+ )?NOTICE IP_LOOKUP :.* Found your hostname/i  && do { register_irc; last SWITCH;  };		

		/^PING :(.*)/i && do { print "PONG $1\n";  last SWITCH; }; 
		

		/^:([\S]+) (?:376|422)/i && do { join_chan;  last SWITCH; }; 
	
   	        /:([^!]+)[^\s]+ PRIVMSG ([^\s]+) :(\!.*)\r/ && do { 
		    ($r_pseudo,$r_name,$r_texte) = ($1,$2,$3); $r_chan = $r_name;
		    $r_chan =~ s/\#//;
		    $r_chan = ${"chan_".$r_chan}; if (!$r_chan) { $r_chan =  " ";  }
		    print STDOUT "passage de : $r_name , $r_chan , $r_pseudo , $r_texte \n";
		    no strict "refs";
		    foncts($r_name,$r_chan,$r_pseudo,$r_texte); };
    	            use strict "refs";
		
		

#   	        /:([^!]+)[^\s]+ PRIVMSG (?:$chan|[^\s]+) :(.*)\r/ && do {  print STDOUT "<$1>$2\n"; }
	
    }    

}

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