mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-22 11:59:43 +01:00
Misc fixes and improvements
applets/random_quote.pl: URI encode arguments Plugins/FuncSed: improve error handling
This commit is contained in:
parent
e4becb22a1
commit
d824255c6e
3
applets/random_quote.pl
vendored
3
applets/random_quote.pl
vendored
@ -6,6 +6,7 @@
|
|||||||
# Quick and dirty by :pragma
|
# Quick and dirty by :pragma
|
||||||
|
|
||||||
use LWP::UserAgent::WithCache;
|
use LWP::UserAgent::WithCache;
|
||||||
|
use URI::Escape;
|
||||||
|
|
||||||
my ($text, $t);
|
my ($text, $t);
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ while (1) {
|
|||||||
my $author = "";
|
my $author = "";
|
||||||
|
|
||||||
$arguments =~ s/\$nick/me/gi;
|
$arguments =~ s/\$nick/me/gi;
|
||||||
$arguments =~ s/\s/+/g;
|
$arguments = uri_escape($arguments);
|
||||||
|
|
||||||
if ($arguments =~ m/\-\-author[\s\+]+(.*)/i) {
|
if ($arguments =~ m/\-\-author[\s\+]+(.*)/i) {
|
||||||
$author = $1;
|
$author = $1;
|
||||||
|
1
cpanfile
1
cpanfile
@ -389,6 +389,7 @@ feature qalc => sub {
|
|||||||
};
|
};
|
||||||
|
|
||||||
feature random_quote => sub {
|
feature random_quote => sub {
|
||||||
|
requires 'URI::Escape';
|
||||||
requires 'LWP::UserAgent::WithCache';
|
requires 'LWP::UserAgent::WithCache';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,11 +33,12 @@ sub func_sed {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $text = "@_";
|
my $text = "@_";
|
||||||
|
|
||||||
|
my $result = eval {
|
||||||
if ($text =~ /^s(.)(.*?)(?<!\\)\1(.*?)(?<!\\)\1(\S*)\s+(.*)/p) {
|
if ($text =~ /^s(.)(.*?)(?<!\\)\1(.*?)(?<!\\)\1(\S*)\s+(.*)/p) {
|
||||||
my ($a, $r, $g, $m, $t) = ($5, "'\"$3\"'", index($4, "g") != -1, $4, $2);
|
my ($a, $r, $g, $m, $t) = ($5, "'\"$3\"'", index($4, "g") != -1, $4, $2);
|
||||||
|
|
||||||
print "a: $a, r: $r, g: $g, m: $m, t: $t\n";
|
#print "a: $a, r: $r, g: $g, m: $m, t: $t\n";
|
||||||
print "text: [$text]\n";
|
#print "text: [$text]\n";
|
||||||
|
|
||||||
if ($m =~ /P/) {
|
if ($m =~ /P/) {
|
||||||
$r =~ s/^'"(.*)"'$/$1/;
|
$r =~ s/^'"(.*)"'$/$1/;
|
||||||
@ -51,8 +52,16 @@ sub func_sed {
|
|||||||
}
|
}
|
||||||
return $a;
|
return $a;
|
||||||
} else {
|
} else {
|
||||||
return "sed: syntax error";
|
return 'sed: syntax error; usage: sed s/<regex>/<replacement>/[Pig]; P preserve case; i ignore case; g replace all';
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (my $e = $@) {
|
||||||
|
$e =~ s/ at .*$//;
|
||||||
|
return "sed: syntax error: $e";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ use PBot::Imports;
|
|||||||
# These are set by the /misc/update_version script
|
# These are set by the /misc/update_version script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 4560,
|
BUILD_REVISION => 4561,
|
||||||
BUILD_DATE => "2022-07-14",
|
BUILD_DATE => "2022-08-03",
|
||||||
};
|
};
|
||||||
|
|
||||||
sub initialize {}
|
sub initialize {}
|
||||||
|
Loading…
Reference in New Issue
Block a user