mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-17 09:29:30 +01:00
FuncBuiltins: add shquote
and quotemeta
This commit is contained in:
parent
bd4fd4ea27
commit
2182b26bfd
@ -56,6 +56,22 @@ sub initialize($self, %conf) {
|
||||
subref => sub { $self->func_unquote(@_) }
|
||||
}
|
||||
);
|
||||
$self->{pbot}->{functions}->register(
|
||||
'shquote',
|
||||
{
|
||||
desc => 'quotes text for sh invocation',
|
||||
usage => 'shquote <text>',
|
||||
subref => sub { $self->func_shquote(@_) }
|
||||
}
|
||||
);
|
||||
$self->{pbot}->{functions}->register(
|
||||
'quotemeta',
|
||||
{
|
||||
desc => 'escapes/quotes metacharacters',
|
||||
usage => 'quotemeta <text>',
|
||||
subref => sub { $self->func_quotemeta(@_) }
|
||||
}
|
||||
);
|
||||
$self->{pbot}->{functions}->register(
|
||||
'uri_escape',
|
||||
{
|
||||
@ -90,6 +106,8 @@ sub unload($self) {
|
||||
$self->{pbot}->{functions}->unregister('uc');
|
||||
$self->{pbot}->{functions}->unregister('lc');
|
||||
$self->{pbot}->{functions}->unregister('unquote');
|
||||
$self->{pbot}->{functions}->unregister('shquote');
|
||||
$self->{pbot}->{functions}->unregister('quotemeta');
|
||||
$self->{pbot}->{functions}->unregister('uri_escape');
|
||||
$self->{pbot}->{functions}->unregister('ana');
|
||||
$self->{pbot}->{functions}->unregister('maybe-the');
|
||||
@ -133,6 +151,17 @@ sub func_lc($self, @rest) {
|
||||
return lc $text;
|
||||
}
|
||||
|
||||
sub func_shquote($self, @rest) {
|
||||
my $text = "@rest";
|
||||
$text =~ s/'/'"'"'/g;
|
||||
return "'$text'";
|
||||
}
|
||||
|
||||
sub func_quotemeta($self, @rest) {
|
||||
my $text = "@rest";
|
||||
return quotemeta $text;
|
||||
}
|
||||
|
||||
sub func_uri_escape($self, @rest) {
|
||||
my $text = "@rest";
|
||||
return uri_escape_utf8($text);
|
||||
|
@ -25,7 +25,7 @@ use PBot::Imports;
|
||||
# These are set by the /misc/update_version script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 4826,
|
||||
BUILD_REVISION => 4827,
|
||||
BUILD_DATE => "2024-11-02",
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user