diff --git a/lib/PBot/Core/Commands.pm b/lib/PBot/Core/Commands.pm index d8305f82..4f953ffa 100644 --- a/lib/PBot/Core/Commands.pm +++ b/lib/PBot/Core/Commands.pm @@ -206,10 +206,8 @@ sub interpreter($self, $context) { $context->{add_nick} = 1; } - unless ($context->{'dont-replace-pronouns'}) { - $context->{arguments} = $self->{pbot}->{factoids}->{variables}->expand_factoid_vars($context, $context->{arguments}); - $context->{arglist} = $self->{pbot}->{interpreter}->make_args($context->{arguments}); - } + $context->{arguments} = $self->{pbot}->{factoids}->{variables}->expand_factoid_vars($context, $context->{arguments}); + $context->{arglist} = $self->{pbot}->{interpreter}->make_args($context->{arguments}); # execute this command as a backgrounded process? if ($self->get_meta($keyword, 'background-process')) { diff --git a/lib/PBot/Core/Factoids/Modifiers.pm b/lib/PBot/Core/Factoids/Modifiers.pm index 3d8da456..6ea54067 100644 --- a/lib/PBot/Core/Factoids/Modifiers.pm +++ b/lib/PBot/Core/Factoids/Modifiers.pm @@ -108,7 +108,7 @@ sub parse($self, $modifier, $bracketed = 0) { next; } - if ($$modifier =~ s/^(enumerate|comma|ucfirst|lcfirst|title|uc|lc|json)//) { + if ($$modifier =~ s/^(enumerate|comma|ucfirst|lcfirst|title|uc|lc|json|quotemeta)//) { $modifiers{$1} = 1; next; } diff --git a/lib/PBot/Core/Factoids/Selectors.pm b/lib/PBot/Core/Factoids/Selectors.pm index b8125629..3596d501 100644 --- a/lib/PBot/Core/Factoids/Selectors.pm +++ b/lib/PBot/Core/Factoids/Selectors.pm @@ -41,6 +41,10 @@ sub make_list($self, $context, $extracted, $settings, %opts) { $item = ucfirst $item; } + if ($settings->{'quotemeta'}) { + $item = quotemeta $item; + } + if ($settings->{'title'}) { $item = ucfirst lc $item; $item =~ s/ (\w)/' ' . uc $1/ge; @@ -50,6 +54,7 @@ sub make_list($self, $context, $extracted, $settings, %opts) { $item = $self->{pbot}->{factoids}->{variables}->escape_json($item); } + push @list, $item; } diff --git a/lib/PBot/Core/Factoids/Variables.pm b/lib/PBot/Core/Factoids/Variables.pm index b970f248..6a2a90ba 100644 --- a/lib/PBot/Core/Factoids/Variables.pm +++ b/lib/PBot/Core/Factoids/Variables.pm @@ -217,7 +217,11 @@ sub expand_factoid_vars($self, $context, $action, %opts) { $fixed_article = ucfirst $fixed_article; } - $replacement = $fixed_article . $trailing . $replacement; + if (not length $replacement) { + $replacement = $fixed_article; + } else { + $replacement = $fixed_article . $trailing . $replacement; + } } # prevent double-spaces when joining replacement to result @@ -241,6 +245,27 @@ sub expand_factoid_vars($self, $context, $action, %opts) { } } + if ($result =~ s/\b(a|an)(\s*)$//i) { + my ($article, $trailing) = ($1, $2); + + my $word = $rest; + $word =~ s/^\s+//; + + my $fixed_article = select_indefinite_article $word; + + if ($article eq 'AN') { + $fixed_article = uc $fixed_article; + } elsif ($article eq 'An' or $article eq 'A') { + $fixed_article = ucfirst $fixed_article; + } + + if (not length $rest) { + $rest = $fixed_article; + } else { + $rest = $fixed_article . $trailing . $rest; + } + } + $result .= $rest; $result = $self->expand_special_vars($from, $nick, $root_keyword, $result); @@ -426,6 +451,10 @@ sub expand_action_arguments($self, $context, $action, $input = '', $nick = '') { $change =~ s/ (\w)/' ' . uc $1/ge; } + if ($settings{'quotemeta'}) { + $change = quotemeta $change; + } + if ($settings{'json'}) { $change = $self->escape_json($change); } diff --git a/lib/PBot/Core/Handlers/ChanOps.pm b/lib/PBot/Core/Handlers/ChanOps.pm index deb3579a..ca592ed9 100644 --- a/lib/PBot/Core/Handlers/ChanOps.pm +++ b/lib/PBot/Core/Handlers/ChanOps.pm @@ -22,11 +22,23 @@ sub initialize($self, %conf) { sub on_self_join($self, $event_type, $event) { my $channel = $event->{channel}; + $self->{pbot}->{logger}->log("self join to $channel\n"); + delete $self->{pbot}->{chanops}->{is_opped}->{$channel}; delete $self->{pbot}->{chanops}->{op_requested}->{$channel}; - if ($self->{pbot}->{channels}->{storage}->get_data($channel, 'permop')) { - $self->{pbot}->{chanops}->gain_ops($channel); + my $nick = $self->{pbot}->{conn}->nick; + + if ($self->{pbot}->{chanops}->can_gain_ops($channel)) { + if ($self->{pbot}->{channels}->{storage}->get_data($channel, 'autovoice')) { + $self->{pbot}->{logger}->log("$nick autovoice in $channel\n"); + $self->{pbot}->{chanops}->add_op_command($channel, "mode $channel +v $nick"); + $self->{pbot}->{chanops}->gain_ops($channel); + } elsif ($self->{pbot}->{channels}->{storage}->get_data($channel, 'permop') + || $self->{pbot}->{channels}->{storage}->get_data($channel, 'autoop')) { + $self->{pbot}->{logger}->log("$nick autoop in $channel\n"); + $self->{pbot}->{chanops}->gain_ops($channel); + } } return 1; diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index 08e5bb82..b38d463e 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,8 +25,8 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4933, - BUILD_DATE => "2026-02-02", + BUILD_REVISION => 4934, + BUILD_DATE => "2026-02-19", }; sub initialize {}