Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 3c57de4ae1878ad082a8cdfcfdaeddef82a3627f
  • master par défaut protégée
2 résultats

channels_controller.rb

Blame
    • Sybil's avatar
      3c57de4a
      O.K. : Tracks contain every useful data. · 3c57de4a
      Sybil a rédigé
       - Tags weren't displayed. Solution : composite_primary_keys gem to manage the shi*** database design.
       - Json unreadable. Solution : active_model_serializers to select json fields.
       - SQL requests too slow. Solution : includes in place of joins (3x faster).
       PS : TY Zar.
      3c57de4a
      Historique
      O.K. : Tracks contain every useful data.
      Sybil a rédigé
       - Tags weren't displayed. Solution : composite_primary_keys gem to manage the shi*** database design.
       - Json unreadable. Solution : active_model_serializers to select json fields.
       - SQL requests too slow. Solution : includes in place of joins (3x faster).
       PS : TY Zar.
    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");