Skip to content
Extraits de code Groupes Projets
Valider 1b3d5d3c rédigé par Alexandre Morignot's avatar Alexandre Morignot
Parcourir les fichiers

-jesuisunspammeur becomes -f and is more clever

parent d7ad3ff1
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -21,18 +21,19 @@ sub exec {
query => ($msg) ? $msg : ''
);
if (scalar @{$query->words} == 1
and scalar @{$query->tags} == 0
my $db_query = utils::db::get->new();
my $rows = $db_query->get_rows($query);
if (scalar @{$query->tags} == 0
and $query->id == -1
and not $query->is_single_word)
and $rows > 10
and not $query->force)
{
$irc->yield(privmsg => $chan => "pour faire une recherche avec un seul mot, ajouter l'option -jesuisunspammeur (sinon on peut faire une recherche en query aussi)");
$irc->yield(privmsg => $chan => "trop de résultats ($rows), utiliser -f pour forcer la recherche");
return;
}
my $db_query = utils::db::get->new();
my $content = $db_query->get($query);
my $rows = $db_query->get_rows($query);
if (!$content) {
if ($rows > 0) {
......
......@@ -24,11 +24,11 @@ has 'is_global' => (
init_arg => undef
);
has 'is_single_word' => (
has 'force' => (
is => 'ro',
isa => 'Bool',
lazy => 1,
builder => '_build_is_single_word',
builder => '_build_force',
init_arg => undef
);
......@@ -67,10 +67,10 @@ sub _build_is_global {
}
}
sub _build_is_single_word {
sub _build_force {
my $self = shift;
if ($self->chan !~ /^#/ || $self->query =~ /(^|\s)-(jesuisunspammeur|1)($|\s)/) {
if ($self->chan !~ /^#/ || $self->query =~ /(^|\s)-f($|\s)/) {
return 1;
} else {
return 0;
......@@ -91,7 +91,7 @@ sub _build_words {
my $query = $self->query;
$query =~ s/(^|\s)-a(ll)?($|\s)/ /;
$query =~ s/(^|\s)-(jesuisunspammeur|1)($|\s)/ /;
$query =~ s/(^|\s)-f($|\s)/ /;
return [$query =~ /(?:^| )([^#\s]+)/g];
}
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter