Skip to content
Extraits de code Groupes Projets
Valider 109329d8 rédigé par TC's avatar TC
Parcourir les fichiers

- Ajout du suffixe en query lorsque nécessaire

- Meilleure gestion des commandes, notamment enable/disable
parent 58673211
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -202,7 +202,7 @@ sub reload_command ...@@ -202,7 +202,7 @@ sub reload_command
my $line = <FILE>; my $line = <FILE>;
chomp $line; chomp $line;
$package = $1 if($line =~ /^\s*package\s+([^ ]+)\s*;/i); $package = $1 if($line =~ /^\s*package\s+([A-Za-z:_-]+)\s*;/i);
$command = $1 if($line =~ /#.*?commands?\s*=\s*([^ ]+)/i); $command = $1 if($line =~ /#.*?commands?\s*=\s*([^ ]+)/i);
$perm = $1 if($line =~ /#.*?rights?\s*=\s*([^ ]+)/i); $perm = $1 if($line =~ /#.*?rights?\s*=\s*([^ ]+)/i);
...@@ -223,7 +223,7 @@ sub reload_command ...@@ -223,7 +223,7 @@ sub reload_command
} }
$::logger->debug("$file: package=$package; perms=$perm") if(defined($::logger)); $::logger->debug("$file: package=$package; perms=$perm") if(defined($::logger));
$package = defined($package) ? $package : ucfirst substr $file, 0, -3; # $package = defined($package) ? $package : ucfirst substr $file, 0, -3;
my $main = ""; my $main = "";
my $save = ""; my $save = "";
...@@ -241,7 +241,7 @@ sub reload_command ...@@ -241,7 +241,7 @@ sub reload_command
$help = $symbol if($symbol =~ /_help$/); $help = $symbol if($symbol =~ /_help$/);
$dbg = $symbol if($symbol =~ /^print_debug$/); $dbg = $symbol if($symbol =~ /^print_debug$/);
} }
strict; use strict;
foreach $command (@commands) foreach $command (@commands)
{ {
...@@ -294,7 +294,9 @@ sub enable ...@@ -294,7 +294,9 @@ sub enable
{ {
my ($self, $chan, $ref_command) = @_; my ($self, $chan, $ref_command) = @_;
my @ret = (); my %ret = ();
if($chan && @{$ref_command})
{
foreach my $commande (@{$ref_command}) foreach my $commande (@{$ref_command})
{ {
# On autorise les * comme méta-caractère # On autorise les * comme méta-caractère
...@@ -310,7 +312,7 @@ sub enable ...@@ -310,7 +312,7 @@ sub enable
if($command =~ $regex) if($command =~ $regex)
{ {
$self->{'_loaded_commands'}->{$command}->{"enable"}->{$chan} = "enable"; $self->{'_loaded_commands'}->{$command}->{"enable"}->{$chan} = "enable";
push @ret, $command; $ret{$command} = '';
} }
} }
} }
...@@ -319,12 +321,44 @@ sub enable ...@@ -319,12 +321,44 @@ sub enable
if(defined($self->{'_loaded_commands'}->{$commande})) if(defined($self->{'_loaded_commands'}->{$commande}))
{ {
$self->{'_loaded_commands'}->{$commande}->{"enable"}->{$chan} = "enable"; $self->{'_loaded_commands'}->{$commande}->{"enable"}->{$chan} = "enable";
push @ret, $commande; $ret{$commande} = '';
}
}
}
}
else
{
foreach my $commande (keys %{$self->{'_loaded_commands'}})
{
foreach my $chan (keys %{$self->{'_loaded_commands'}->{$commande}->{"enable"}})
{
if($self->{'_loaded_commands'}->{$commande}->{"enable"}->{$chan} eq "disable")
{
if(defined($ret{$chan}))
{
push @{$ret{$chan}}, $commande;
}
else
{
$ret{$chan} = [$commande];
}
} }
} }
} }
return @ret; # TODO optimiser en fournissant un if($::logger->isDebug, isInfo, ...)
$::logger->debug("Reporting disabled commands per chan:");
foreach my $chan (keys %ret)
{
$::logger->debug(" $chan:");
foreach my $command (@{$ret{$chan}})
{
$::logger->debug(" - $command");
}
}
}
return %ret;
} # Fin enable } # Fin enable
...@@ -336,7 +370,9 @@ sub disable ...@@ -336,7 +370,9 @@ sub disable
{ {
my ($self, $chan, $ref_command) = @_; my ($self, $chan, $ref_command) = @_;
my @ret = (); my %ret = ();
if($chan && @{$ref_command})
{
foreach my $commande (@{$ref_command}) foreach my $commande (@{$ref_command})
{ {
# On autorise les * comme méta-caractère # On autorise les * comme méta-caractère
...@@ -356,7 +392,7 @@ sub disable ...@@ -356,7 +392,7 @@ sub disable
if($command =~ $regex) if($command =~ $regex)
{ {
$self->{'_loaded_commands'}->{$command}->{"enable"}->{$chan} = "disable"; $self->{'_loaded_commands'}->{$command}->{"enable"}->{$chan} = "disable";
push @ret, $command; $ret{$command} = '';
} }
} }
...@@ -368,12 +404,44 @@ sub disable ...@@ -368,12 +404,44 @@ sub disable
if(defined($self->{'_loaded_commands'}->{$commande})) if(defined($self->{'_loaded_commands'}->{$commande}))
{ {
$self->{'_loaded_commands'}->{$commande}->{"enable"}->{$chan} = "disable"; $self->{'_loaded_commands'}->{$commande}->{"enable"}->{$chan} = "disable";
push @ret, $commande; $ret{$commande} = '';
}
}
}
}
else
{
foreach my $commande (keys %{$self->{'_loaded_commands'}})
{
foreach my $chan (keys %{$self->{'_loaded_commands'}->{$commande}->{"enable"}})
{
if($self->{'_loaded_commands'}->{$commande}->{"enable"}->{$chan} eq "disable")
{
if(defined($ret{$chan}))
{
push @{$ret{$chan}}, $commande;
}
else
{
$ret{$chan} = [$commande];
}
}
}
}
# TODO optimiser en fournissant un if($::logger->isDebug, isInfo, ...)
$::logger->debug("Reporting disabled commands per chan:");
foreach my $chan (keys %ret)
{
$::logger->debug(" $chan:");
foreach my $command (@{$ret{$chan}})
{
$::logger->debug(" - $command");
} }
} }
} }
return @ret; return %ret;
} # Fin disable } # Fin disable
...@@ -623,7 +691,6 @@ sub print_debug ...@@ -623,7 +691,6 @@ sub print_debug
if(defined($ref_params->[0])) if(defined($ref_params->[0]))
{ {
@commands = @{$ref_params}; @commands = @{$ref_params};
} }
else else
{ {
......
...@@ -240,6 +240,15 @@ sub on_private ...@@ -240,6 +240,15 @@ sub on_private
$self->privmsg($Config::owner, "There's ".$event->{'nick'}." who is telling me: ".$event->{'args'}[0]); $self->privmsg($Config::owner, "There's ".$event->{'nick'}." who is telling me: ".$event->{'args'}[0]);
} }
# On ajoute ${Config::suffixe} s'il n'est pas déjà présent
my $text = $event->{'args'}[0];
my $cs = $Config::command_sign;
if(substr($text, 0, length($cs)) ne $cs)
{
$event->{'args'}[0] = $cs.$text;
}
# Received query but transmitting to public event
on_public($self, $event); on_public($self, $event);
} # Fin on_private } # Fin on_private
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter