Tfe

Ongi etorri tfe-ren webgunera...

Old stuff/Perl/droyer_irc/fonctions.pl

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


sub foncts(@)
{
	($chan,$fullpower,$nick,$texte) = ($_[0],$_[1],$_[2],$_[3]);
if ($texte =~ /\@time/) { print "PRIVMSG $chan :$nick: Feignant!\n"; }
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!op (.*)/) { 
		print "mode $chan +o $1\n";
	}
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!say (.*)/) { 
		print "PRIVMSG $debug :$1\n"; #chr(2) = Gras
	}
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!chan (\#\w+)/) { 
			print "PART $chan :chan\n";
			$chan = $1;
			print "JOIN $chan\n";
		
			open(NICK_OPEN,"config");
			my @temp_nick = <NICK_OPEN>;
			close NICK_OPEN;
		
			open(NICK_WRITE,">config");
			foreach(@temp_nick)
			{
				if (/^\$chan/) { print NICK_WRITE "\$chan=\"$chan\";\n"; }
				else { print NICK_WRITE "$_"; }
			}
			close NICK_WRITE;
			
		
		
	}
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!cycle/) { 
			print "PART $chan\n";
			print "JOIN $chan\n";
			print "PRIVMSG $debug :Cycle ...\n";
		
	}
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!directcom (.*)/) { 
		print STDOUT "\n\n /\$\\DIRECTOM! /\$\\  $1\n\n";
		print "$1\n";
	}
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!join/) { 
		print "PRIVMSG $debug :Join del canal $chan\n";
		join_chan;
	}
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!k (.*)/) { 
		print "KICK $chan $1 :fuera !";
		print "PRIVMSG $debug :KICK $1 : fuera !\n";
		
	}
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!kb (.*)/) { 
		my $temp_kb = $1;
		
		print "KICK $chan ".(split " ",$temp_kb)[0]." :non mais, on se croit ou la?\n";
		print "MODE  $chan +b $temp_kb*!*\@*\n";
		print "PRIVMSG $debug :KB $temp_kb\n";
	}
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!nick (\w+)/) { 
			$bot_nick = $1;
			print "NICK :$bot_nick\n";
		
			open(NICK_OPEN,"config");
			my @temp_nick = <NICK_OPEN>;
			close NICK_OPEN;
		
			open(NICK_WRITE,">config");
			foreach(@temp_nick)
			{
				if (/bot_nick/) { print NICK_WRITE "\$bot_nick=\"$bot_nick\";\n"; }
				else { print NICK_WRITE "$_"; }
			}
			close NICK_WRITE;
			
		
		
	}
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!part/) { 
		print "PART $chan :1 bot less";
	}
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!config/) { 
		print "PRIVMSG $debug :fullpower: $fullpower\n";
	}
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!quit/) { 
		print "PART $chan :1 bot less\n";
		print "PRIVSG $debug :Quit del canal $chan\n";
	}
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!reload/) { 
			foreach(split(" ",$fichiers_a_charger))
			{
				print STDOUT "$_\t";
				do "$_" or print "PRIVMSG $debug :[ERREUR] $!";
				print STDOUT "[OK]\n";
			}
			open(INFO,"config");
			while(<INFO>)
			{
			if (/\$fullpower="(.*)";/)
			    {
			    $fullpower=$1;
			    }
		    }
		    print "PRIVMSG $debug :config reloaded !\n";	}
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!topic (.*)/) { 
		print "TOPIC $chan :$1\n";
		print "PRIVMSG $debug :Topic modificado ($1)\n";
	}
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!figlet (.*)/) { 
		
		@affiche=qx/figlet $1/;
		foreach (@affiche)
		{
		print "privmsg $chan :$_\n";
		}
	}
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!owner (\w+)/) { 
			$owner = $1;
		
			open(OWNER_OPEN,"config");
			my @temp_OWNER = <OWNER_OPEN>;
			close OWNER_OPEN;
		
			open(OWNER_WRITE,">config");
			foreach(@temp_OWNER)
			{
				if (/\$owner=/) { print OWNER_WRITE "\$owner=\" $owner \";\n"; }
				else { print OWNER_WRITE "$_"; }
			}
			close OWNER_WRITE;
			print "PRIVMSG $debug :Modificado owner : $owner \n";
			
			
		
		
	}
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!Admin add ([^\s]*)/) { 
			$ajout = $1;
		
			if ($fullpower !~ / $ajout /) 
			{
			    $chan =~ s/\#//g;
			   $fullpower = $fullpower.$ajout." ";	
			    print "PRIVMSG $debug :Anadido $1 en el control del bot .\n";
			    
		
			    open(CONF_OPEN,"config");
			    my @temp_nick = <CONF_OPEN>;
			    close CONF_OPEN;
			
		
			    open(CONF_WRITE,">config");
			    foreach(@temp_nick)
			    {
			  	if (/^\$chan_$chan/) { print "PRIVMSG \#$chan :AJOUT en cours ..\n"; print CONF_WRITE "\$chan_$chan=\"$fullpower \";\n"; $aajout=1;}
			 	else { print CONF_WRITE "$_"; }
			    }
			    if (!$aajout)
			    {  print "PRIVMSG \#$chan :AJOUT en cours ..\n"; print CONF_WRITE "\$chan_$chan=\"$fullpower \";\n";  } 
			    
			    close CONF_WRITE;
			}
			else 
			{
			    print "PRIVMSG $debug :$ajout ya es Admin\n";	
			}
			
		
		
	}
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!Admin del ([^\s]*)/) { 
			$ajout = $1;
			if ($fullpower =~ / $ajout /) 
			{
			    print "PRIVMSG $debug :Suppression de $1 pour le controle du bot.\n";
		    $chan =~ s/\#//;
			$fullpower =~ s/ $ajout //;	    
		
		        open(CONF_OPEN,"config");
		        my @temp_nick = <CONF_OPEN>;
		        close CONF_OPEN;
			
		
			    open(CONF_WRITE,">config");
			    foreach(@temp_nick)
			    {
			  	if (/^\$fullpower/) { print CONF_WRITE "\$chan_$chan=\"$fullpower \";\n"; }
			 	else { print CONF_WRITE "$_"; }
			    }
			    close CONF_WRITE;
			}
			else 
			{
			    print "PRIVMSG $debug :$ajout no es admin  :(\n";	
			}
			
		
		
	}
	elsif ($fullpower =~ / $nick / and $texte =~ /^\!Access/) { 
			$ajout = $1;
		
			if ($fullpower !~ / $ajout /) 
			{
			   $fullpower = $fullpower.$ajout." ";	
			    print "PRIVMSG $debug :Anadido $1 en el control del bot .\n";
			    
		
			    open(CONF_OPEN,"config");
			    my @temp_nick = <CONF_OPEN>;
			    close CONF_OPEN;
			
		
			    open(CONF_WRITE,">config");
			    foreach(@temp_nick)
			    {
			  	if (/^\$fullpower/) { print CONF_WRITE "\$fullpower=\"$fullpower \";\n"; }
			 	else { print CONF_WRITE "$_"; }
			    }
			    close CONF_WRITE;
			}
			else 
			{
			    print "PRIVMSG $debug :$ajout ya es Admin\n";	
			}
			
		
		
	}
}  
 return 1;