mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-22 20:09:43 +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 $def_type = $config->def_type;
|
||||
|
||||
my $def_contains = $config->def_contains;
|
||||
|
||||
# normalize '*' to '.*'
|
||||
$def_type =~ s/\.\*/*/g;
|
||||
$def_type =~ s/\*/.*/g;
|
||||
|
||||
# normalize '*' to '.*'
|
||||
$def_contains =~ s/\.\*/*/g;
|
||||
$def_contains =~ s/\*/.*/g;
|
||||
|
||||
eval {
|
||||
foreach my $type (keys %$defs) {
|
||||
next if $type eq 'word';
|
||||
@ -115,6 +120,7 @@ sub define_word
|
||||
print "$comma$type: " if length $type;
|
||||
foreach my $number (sort { $a <=> $b } keys %{ $defs->{$type} }) {
|
||||
next unless $number >= $config->def_number;
|
||||
next unless $defs->{$type}{$number} =~ m/$def_contains/i;
|
||||
print "$comma" unless $number == 1;
|
||||
print "$number) $defs->{$type}{$number}";
|
||||
$comma = ", ";
|
||||
@ -326,6 +332,7 @@ sub initialise
|
||||
$config->define('database', { ARGCOUNT => 1, ALIAS => 'd' });
|
||||
$config->define('def_number', { ARGCOUNT => 1, ALIAS => 'n', DEFAULT => 1 });
|
||||
$config->define('def_type', { ARGCOUNT => 1, ALIAS => 't', DEFAULT => '*'});
|
||||
$config->define('def_contains', { ARGCOUNT => 1, ALIAS => 'search', DEFAULT => '*'});
|
||||
|
||||
=cut
|
||||
$config->define('match', { ARGCOUNT => 0, ALIAS => 'm' });
|
||||
|
Loading…
Reference in New Issue
Block a user