Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • fbdfe0f74666fb023fa102146de6b2da49121bd3
  • arise par défaut
  • list
3 résultats

Usurp.pm

Blame
  • Usurp.pm 1,49 Kio
    package Usurp; # right = owner ; command = usurp
    
    
    use strict;
    use warnings;
    
    
    # ###
    #  usurp_main
    # Usurpe l'identité d'un autre utilisateur le temps d'une commande, si le user
    # est admin
    # 
    # Usage :
    #  !usurp [<reply to>] nick!user@host command ...
    # ###
    sub usurp_main
    {
    	my ($conn, $event, $reply_to, $ref_params) = @_;
    	
    	return 0 unless defined($ref_params->[1]);
    	
    	$reply_to = lc $reply_to;
    	
    	if($ref_params->[0] !~ /^(.*?)!(.*?)\@(.*?)$/i)
    	{
    		$reply_to = shift @{$ref_params};
    	}
    	
    	my $unh = shift @{$ref_params};
    	my $commande = shift @{$ref_params};
    	
    	if($unh =~ /^(.*?)!(.*?)\@(.*?)$/i)
    	{
    		my ($nick, $user, $host) = ($1, $2, $3);
    		
    		$event->{'from'} = $unh;
    		$event->{'nick'} = $nick;
    		$event->{'user'} = $user;
    		$event->{'host'} = $host;
    		$event->{'userhost'} = $user.'@'.$host;
    	}
    	else
    	{
    		return 0;
    	}
    	
    	$event->{'to'}[0] = $reply_to;
    	$event->{'args'} = [
    		$Config::command_sign.$commande.' '.join(' ', @{$ref_params})
    	];
    	
    	$::logger->debug("Running process_command with identity '$unh'");
    	$conn->{'cmdtool'}->process_command($commande, $ref_params, $conn, $event, $reply_to);
    	
    	return 1;
    } # Fin usurp_main
    
    
    # ###
    #  usurp_help
    # Affiche l'aide de la commande '!usurp'
    # ###
    sub usurp_help
    {
    	my ($self, $event, $reply_to, $ref_params) = @_;
    	
    	$self->privmsg($reply_to, "`".$Config::command_sign."usurp [<reply to>] ".
    	               "nick!user\@host command ...` ".
    				   "=> usurp a user, and a chan if provided, for a command");