mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-23 04:19:27 +01:00
Added -search option to dict.org.pl
This commit is contained in:
parent
a5618c41a1
commit
1131ab8bba
@ -103,11 +103,16 @@ sub define_word
|
|||||||
|
|
||||||
my $comma = '';
|
my $comma = '';
|
||||||
my $def_type = $config->def_type;
|
my $def_type = $config->def_type;
|
||||||
|
my $def_contains = $config->def_contains;
|
||||||
|
|
||||||
# normalize '*' to '.*'
|
# normalize '*' to '.*'
|
||||||
$def_type =~ s/\.\*/*/g;
|
$def_type =~ s/\.\*/*/g;
|
||||||
$def_type =~ s/\*/.*/g;
|
$def_type =~ s/\*/.*/g;
|
||||||
|
|
||||||
|
# normalize '*' to '.*'
|
||||||
|
$def_contains =~ s/\.\*/*/g;
|
||||||
|
$def_contains =~ s/\*/.*/g;
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
foreach my $type (keys %$defs) {
|
foreach my $type (keys %$defs) {
|
||||||
next if $type eq 'word';
|
next if $type eq 'word';
|
||||||
@ -115,6 +120,7 @@ sub define_word
|
|||||||
print "$comma$type: " if length $type;
|
print "$comma$type: " if length $type;
|
||||||
foreach my $number (sort { $a <=> $b } keys %{ $defs->{$type} }) {
|
foreach my $number (sort { $a <=> $b } keys %{ $defs->{$type} }) {
|
||||||
next unless $number >= $config->def_number;
|
next unless $number >= $config->def_number;
|
||||||
|
next unless $defs->{$type}{$number} =~ m/$def_contains/i;
|
||||||
print "$comma" unless $number == 1;
|
print "$comma" unless $number == 1;
|
||||||
print "$number) $defs->{$type}{$number}";
|
print "$number) $defs->{$type}{$number}";
|
||||||
$comma = ", ";
|
$comma = ", ";
|
||||||
@ -326,6 +332,7 @@ sub initialise
|
|||||||
$config->define('database', { ARGCOUNT => 1, ALIAS => 'd' });
|
$config->define('database', { ARGCOUNT => 1, ALIAS => 'd' });
|
||||||
$config->define('def_number', { ARGCOUNT => 1, ALIAS => 'n', DEFAULT => 1 });
|
$config->define('def_number', { ARGCOUNT => 1, ALIAS => 'n', DEFAULT => 1 });
|
||||||
$config->define('def_type', { ARGCOUNT => 1, ALIAS => 't', DEFAULT => '*'});
|
$config->define('def_type', { ARGCOUNT => 1, ALIAS => 't', DEFAULT => '*'});
|
||||||
|
$config->define('def_contains', { ARGCOUNT => 1, ALIAS => 'search', DEFAULT => '*'});
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
$config->define('match', { ARGCOUNT => 0, ALIAS => 'm' });
|
$config->define('match', { ARGCOUNT => 0, ALIAS => 'm' });
|
||||||
|
Loading…
Reference in New Issue
Block a user