diff --git a/lib/PBot/Plugin/FuncBuiltins.pm b/lib/PBot/Plugin/FuncBuiltins.pm index f3e96b68..4f5175a3 100644 --- a/lib/PBot/Plugin/FuncBuiltins.pm +++ b/lib/PBot/Plugin/FuncBuiltins.pm @@ -104,7 +104,6 @@ sub initialize($self, %conf) { subref => sub { $self->func_maybe_to(@_) } } ); - $self->{pbot}->{functions}->register( 'maybe-on', { @@ -113,6 +112,14 @@ sub initialize($self, %conf) { subref => sub { $self->func_maybe_on(@_) } } ); + $self->{pbot}->{functions}->register( + 'length', + { + desc => 'print length of text', + usage => 'length ', + subref => sub { $self->func_length(@_) } + } + ); $self->{tagger} = Lingua::EN::Tagger->new; } @@ -285,4 +292,11 @@ sub func_maybe_on($self, @rest) { return $text; } +sub func_length($self, @rest) { + my $text = "@rest"; + my $count = 0; + while ($text =~ /\X/g) { $count++ }; # count graphemes + return $count; +} + 1;