mirror of
https://github.com/pragma-/pbot.git
synced 2026-02-21 16:58:00 +01:00
Core: misc updates
* added quotemeta modifier * fixed double-spacing in a/an article correction when expanding variables * auto-voice/auto-op on self-join
This commit is contained in:
parent
520912da20
commit
a9299d47f3
@ -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')) {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user