From 608766f8f83dc4c61a86e2821a8529163ffbdff6 Mon Sep 17 00:00:00 2001 From: Ryan Voots Date: Thu, 26 Sep 2019 16:40:04 -0400 Subject: [PATCH] work on factoid edit threshold --- plugins/factoids.pm | 5 +++-- plugins/seen.pm | 2 ++ plugins/supereval.pm | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/factoids.pm b/plugins/factoids.pm index 9abd1ca..8ac71f6 100644 --- a/plugins/factoids.pm +++ b/plugins/factoids.pm @@ -8,6 +8,7 @@ use strict; use Encode qw/decode/; use Data::Dumper; +use List::Util qw/min max/; ############################# # BIG WARNING ABOUT THE DATABASE IN HERE. @@ -840,9 +841,9 @@ sub _metaphone_matches { $metaphone ); - use Text::Levenshtein qw/distance/; # only import it in this scope + use Text::Levenshtein qw/distance/; # only import it in this scope - my $threshold = 4; + my $threshold = int(max(4, min(10, 4+length($subject)/7))); my @sorted = map {$_->[0]} sort {$a->[1] <=> $b->[1]} grep {$_->[1] < $threshold} map {[$_->[1], distance($subject, $_->[1])]} grep {$_->[2] =~ /\S/} @$rows ; return [grep {$_} @sorted[0..9]]; diff --git a/plugins/seen.pm b/plugins/seen.pm index 18debf3..017dde3 100644 --- a/plugins/seen.pm +++ b/plugins/seen.pm @@ -49,6 +49,8 @@ sub command { my( $self, $said, $pm ) = @_; my( $target ) = @{ $said->{recommended_args} }; + return () unless $said->{addressed}; + my $seen = $self->dbh->selectrow_arrayref( "SELECT user,message,seen_date FROM seen WHERE lc_user = ?", undef, l_irc( $target ) diff --git a/plugins/supereval.pm b/plugins/supereval.pm index f365196..fbac734 100644 --- a/plugins/supereval.pm +++ b/plugins/supereval.pm @@ -58,7 +58,7 @@ sub make_pastebin_all { } } -my @versions = ('', 't', qw(1 2 3 4 5.0 5.1 5.2 5.3 5.4 5.5 tall all rall), map {$_, $_."t"} qw/5.6 5.8 5.8.4 5.8.8 5.10 5.10.0 5.12 5.14 5.16 5.18 5.20 5.22 5.24 5.26 5.28 5.30/); +my @versions = ('', 't', qw(1 2 3 4 5.0 5.1 5.2 5.3 5.4 5.5 tall all rall yall), map {$_, $_."t"} qw/5.6 5.8 5.8.4 5.8.8 5.10 5.10.0 5.12 5.14 5.16 5.18 5.20 5.22 5.24 5.26 5.28 5.30 5.30.0 5.28.2 5.28.1 5.28.0 5.26.3 5.26.2 5.26.1 5.26.0 5.24.4 5.24.3 5.24.2 5.24.1 5.24.0 5.22.4 5.22.3 5.22.2 5.22.1 5.22.0 5.20.3 5.20.2 5.20.1 5.20.0 5.18.4 5.18.3 5.18.2 5.18.1 5.18.0 5.16.3 5.16.2 5.16.1 5.16.0 5.14.4 5.14.3 5.14.2 5.14.1 5.14.0 5.12.5 5.12.4 5.12.3 5.12.2 5.12.1 5.12.0 5.10.1 5.10.0 5.8.9 5.8.8 5.8.7 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.6.2 5.6.1 5.6.0/); sub new { my( $class ) = @_; @@ -176,6 +176,8 @@ sub command { $resultstr = make_pastebin_all($said->{channel}, $code, "t"); } elsif ($type =~ /perlrall/) { $resultstr = make_pastebin_all($said->{channel}, $code, "r"); + } elsif ($type =~ /perlyall/) { + $resultstr = make_pastebin_all($said->{channel}, $code, "y"); } elsif ($pbflag) { my $output = $self->do_singleeval($type, $code); $resultstr = make_pastebin($said->{channel}, $output);