1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut synced 2025-06-07 15:55:42 -04:00

support more substituion syntax

This commit is contained in:
Ryan Voots 2017-03-24 18:44:59 -04:00
parent 04f1b403c2
commit 90c7e35d4a

View file

@ -240,8 +240,13 @@ sub sub_command {
#i lost the object oriented calling here, but i don't care too much, BECAUSE this avoids using strings for the calling, i might change that. #i lost the object oriented calling here, but i don't care too much, BECAUSE this avoids using strings for the calling, i might change that.
$fact_string = $commandhash{$1}->($self,$subject, $said->{name}, $said); $fact_string = $commandhash{$1}->($self,$subject, $said->{name}, $said);
} }
elsif (($subject =~ m|^\s*(.*?)\s*=~\s*s/([^/]+)/([^/]*)/([gi]*)\s*$|i) || elsif (
($subject =~ m/^\s*(.*?)\s*=~\s*s\{(.+)\}\{(.*)\}([gi]*)\s*$/i)) ($subject =~ m{\w\s*=~\s*s /.+ / .* /[gi]*\s*$}ix) ||
($subject =~ m{\w\s*=~\s*s\|.+\| .*\|[gi]*\s*$}ix) ||
($subject =~ m{\w\s*=~\s*s\{.+\}\{.*\}[gi]*\s*$}ix) ||
($subject =~ m{\w\s*=~\s*s <.+ > <.* >[gi]*\s*$}ix) ||
($subject =~ m{\w\s*=~\s*s\(.+\)\(.*\)[gi]*\s*$}ix)
)
{ {
$fact_string = $self->get_fact_substitute( $subject, $said->{name}, $said); $fact_string = $self->get_fact_substitute( $subject, $said->{name}, $said);
} }
@ -534,8 +539,13 @@ sub _fact_substitute
sub get_fact_substitute { sub get_fact_substitute {
my( $self, $subject, $name, $said ) = @_; my( $self, $subject, $name, $said ) = @_;
if (($said->{body} =~ m|^(?:\s*substitute)?\s*(.*?)\s*=~\s*s/([^/]+)/([^/]*)/([gi]*)\s*$|i) || if (
($said->{body} =~ m/^(?:\s*substitute)?\s*(.*?)\s*=~\s*s\{(.+)\}\{(.*?)\}([gi]*)\s*$/i)) ($said->{body} =~ m{^(?:\s*substitute)?\s*(.*?)\s*=~\s*s /([^/]+ ) /([^/]* )/([gi]*)\s*$}ix) ||
($said->{body} =~ m{^(?:\s*substitute)?\s*(.*?)\s*=~\s*s\|([^|]+ ) \|([^|]* )\|([gi]*)\s*$}ix) ||
($said->{body} =~ m{^(?:\s*substitute)?\s*(.*?)\s*=~\s*s\{([^\}]+)\}\{([^\}]*?)\}([gi]*)\s*$}ix) ||
($said->{body} =~ m{^(?:\s*substitute)?\s*(.*?)\s*=~\s*s\(([^)]+ )\)\(([^)]*? )\)([gi]*)\s*$}ix) ||
($said->{body} =~ m{^(?:\s*substitute)?\s*(.*?)\s*=~\s*s <([^>]+ ) > <([^>]*? ) >([gi]*)\s*$}ix)
)
{ {
my ($subject, $match, $subst, $flags) = ($1, $2, $3, $4); my ($subject, $match, $subst, $flags) = ($1, $2, $3, $4);