3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-31 23:22:37 +01:00

Replace preserve_whitespace metadata with condense-whitespace

PBot now preserves whitespace by default. The `preserve_whitespace`
metadata field is now redundant. It has now been replaced with
`condense-whitespace`, which when set to a true value will collapse
adjacent whitespace to a single space.
This commit is contained in:
Pragmatic Software 2024-11-04 00:25:36 -08:00
parent 41c5182208
commit 9ebc77f4da
No known key found for this signature in database
GPG Key ID: CC916B6E3C84ECCE
12 changed files with 28 additions and 34 deletions

9
data/commands vendored
View File

@ -191,7 +191,7 @@
}, },
"factlog" : { "factlog" : {
"help" : "Displays a factoid's changelog history. See https://github.com/pragma-/pbot/blob/master/doc/Factoids.md#factlog", "help" : "Displays a factoid's changelog history. See https://github.com/pragma-/pbot/blob/master/doc/Factoids.md#factlog",
"requires_cap" : 0 "requires_cap" : "0"
}, },
"factmove" : { "factmove" : {
"help" : "Renames a factoid or moves a factoid to a different channel. See https://github.com/pragma-/pbot/blob/master/doc/Factoids.md#factmove", "help" : "Renames a factoid or moves a factoid to a different channel. See https://github.com/pragma-/pbot/blob/master/doc/Factoids.md#factmove",
@ -247,6 +247,7 @@
"requires_cap" : "0" "requires_cap" : "0"
}, },
"grab" : { "grab" : {
"dont-replace-pronouns" : "1",
"help" : "Grabs a message someone says, and adds it to the quotegrabs database. https://github.com/pragma-/pbot/blob/master/doc/Plugins/Quotegrabs.md#grab", "help" : "Grabs a message someone says, and adds it to the quotegrabs database. https://github.com/pragma-/pbot/blob/master/doc/Plugins/Quotegrabs.md#grab",
"requires_cap" : "0" "requires_cap" : "0"
}, },
@ -353,13 +354,11 @@
"plang" : { "plang" : {
"dont-replace-pronouns" : "1", "dont-replace-pronouns" : "1",
"help" : "", "help" : "",
"preserve_whitespace" : "1",
"requires_cap" : "0" "requires_cap" : "0"
}, },
"plangrepl" : { "plangrepl" : {
"dont-replace-pronouns" : "1", "dont-replace-pronouns" : "1",
"help" : "", "help" : "",
"preserve_whitespace" : "1",
"requires_cap" : 0 "requires_cap" : 0
}, },
"plug" : { "plug" : {
@ -381,6 +380,7 @@
"recall" : { "recall" : {
"dont-replace-pronouns" : "0", "dont-replace-pronouns" : "0",
"help" : "Recalls previous chat history for a channel. See https://github.com/pragma-/pbot/blob/master/doc/Admin.md#recall", "help" : "Recalls previous chat history for a channel. See https://github.com/pragma-/pbot/blob/master/doc/Admin.md#recall",
"keep-escapes" : "1",
"requires_cap" : "0" "requires_cap" : "0"
}, },
"refresh" : { "refresh" : {
@ -397,7 +397,7 @@
}, },
"regfind" : { "regfind" : {
"help" : "Searches the registry for keywords or values. See https://github.com/pragma-/pbot/blob/master/doc/Registry.md#regfind", "help" : "Searches the registry for keywords or values. See https://github.com/pragma-/pbot/blob/master/doc/Registry.md#regfind",
"requires_cap" : 0 "requires_cap" : "0"
}, },
"regset" : { "regset" : {
"help" : "Creates a new registry item or updates an existing item. See https://github.com/pragma-/pbot/blob/master/doc/Registry.md#regset", "help" : "Creates a new registry item or updates an existing item. See https://github.com/pragma-/pbot/blob/master/doc/Registry.md#regset",
@ -531,7 +531,6 @@
}, },
"wordle" : { "wordle" : {
"help" : "Wordle game! Guess target word by submitting words for clues about which letters belong to the word!", "help" : "Wordle game! Guess target word by submitting words for clues about which letters belong to the word!",
"preserve_whitespace" : "1",
"requires_cap" : null "requires_cap" : null
}, },
"wordmorph" : { "wordmorph" : {

BIN
data/factoids.sqlite3 vendored

Binary file not shown.

View File

@ -620,7 +620,7 @@ Name | Description
`cap-required` | When set to a true value then the command requires that users have the `can-<command name>` [capability](#user-capabilities) before they can invoke it. `cap-required` | When set to a true value then the command requires that users have the `can-<command name>` [capability](#user-capabilities) before they can invoke it.
`dont-replace-pronouns` | When set to a true value then pronouns such as "my", "me", "your", etc, will not be intuitively replaced with nicks and such. `dont-replace-pronouns` | When set to a true value then pronouns such as "my", "me", "your", etc, will not be intuitively replaced with nicks and such.
`background-process` | When set to a true value then this command will be executed as a background process. Use this for commands that can potentially take a long time to complete. `background-process` | When set to a true value then this command will be executed as a background process. Use this for commands that can potentially take a long time to complete.
`preserve_whitespace` | When set to a true value, do not collapse ajdacent whitespace characters in command output. `condense-whitespace` | When set to a true value, collapse ajdacent whitespace characters in command output.
`process-timeout` | The timeout, in seconds, before the process is automatically killed. If not set then the `processmanager.default_timeout` [registry](Registry.md) value will be used. `process-timeout` | The timeout, in seconds, before the process is automatically killed. If not set then the `processmanager.default_timeout` [registry](Registry.md) value will be used.
## Event-queue management ## Event-queue management

View File

@ -86,18 +86,18 @@ For example:
<PBot> a <PBot> a
<PBot> b <PBot> b
<PBot> c <PBot> c
<PBot> And that's all I have to say about that. See https://0x0.st/-Okb.txt for full text. <PBot> <truncated; https://0x0.st/Okb.txt>
## I made a command. It's supposed to output formatting with spaces and tabs? ## How can I remove excessive spaces and tabs from command output?
By default, PBot collapses adjacent whitespace in command output. This is intended to If a command or factoid is producing too much whitespace and making it
reduce visual noise in IRC channels. difficult to read, you enable a metadata option to collapse adjacent
whitespace to a single space.
If your command is registered by a plugin, use the [`cmdset`](Admin.md#cmdset) command If your command is registered by a plugin, use the [`cmdset`](Admin.md#cmdset) command
to set the `preserve_whitespace` [command metadata](Admin.md#command-metadata-list) to to set the `condense-whitespace` [command metadata](Admin.md#command-metadata-list).
control this behavior.
If your command is a command-line applet, use the [`factset`](Factoids.md#factset) command If your command is a command-line applet, use the [`factset`](Factoids.md#factset) command
to set the `preserve_whitespace` [factoid metadata](Factoids.md#factoid-metadata-list) instead. to set the `condense-whitespace` [factoid metadata](Factoids.md#factoid-metadata-list) instead.
## How do I change my password? ## How do I change my password?
If you have a NickServ account or a unique hostmask, you don't need a PBot password. If you have a NickServ account or a unique hostmask, you don't need a PBot password.

View File

@ -634,7 +634,7 @@ Name | Capability | Description
`locked_to_channel` | none | This factoid can only be invoked in the channel in which it was created. `locked_to_channel` | none | This factoid can only be invoked in the channel in which it was created.
`allow_empty_args` | none | Do not replace empty arguments with `$nick`. `allow_empty_args` | none | Do not replace empty arguments with `$nick`.
`require_explicit_args` | none | Aliases must have explicit `$args`. `require_explicit_args` | none | Aliases must have explicit `$args`.
`preserve_whitespace` | none | Do not collapse ajdacent whitespace characters. `condense-whitespace` | none | Collapse ajdacent whitespace characters.
## Information about factoids ## Information about factoids
### factfind ### factfind

View File

@ -194,8 +194,8 @@ sub interpreter($self, $context) {
} }
} }
if ($self->get_meta($keyword, 'preserve_whitespace')) { if ($self->get_meta($keyword, 'condense-whitespace')) {
$context->{preserve_whitespace} = 1; $context->{'condense-whitespace'} = 1;
} }
# tell PBot::Core::Interpreter to prepend caller's nick to output # tell PBot::Core::Interpreter to prepend caller's nick to output

View File

@ -982,8 +982,6 @@ sub cmd_factshow($self, $context) {
my $factoids = $self->{pbot}->{factoids}->{data}->{storage}; my $factoids = $self->{pbot}->{factoids}->{data}->{storage};
$context->{preserve_whitespace} = 1;
my ($chan, $trig) = @$opt_args; my ($chan, $trig) = @$opt_args;
$chan = $context->{from} if not defined $trig; $chan = $context->{from} if not defined $trig;
my $args = join(' ', map { $_ = "'$_'" if $_ =~ m/ /; $_ } @$opt_args); my $args = join(' ', map { $_ = "'$_'" if $_ =~ m/ /; $_ } @$opt_args);
@ -1311,8 +1309,6 @@ sub cmd_factchange($self, $context) {
my $factoids_data = $self->{pbot}->{factoids}->{data}->{storage}; my $factoids_data = $self->{pbot}->{factoids}->{data}->{storage};
my ($channel, $trigger, $keyword, $delim, $tochange, $changeto, $modifier, $url); my ($channel, $trigger, $keyword, $delim, $tochange, $changeto, $modifier, $url);
$context->{preserve_whitespace} = 1;
my $needs_disambig; my $needs_disambig;
if (length $context->{arguments}) { if (length $context->{arguments}) {

View File

@ -19,6 +19,7 @@ our %factoid_metadata = (
'allow_empty_args' => 'INTEGER', 'allow_empty_args' => 'INTEGER',
'background-process' => 'INTEGER', 'background-process' => 'INTEGER',
'cap-override' => 'TEXT', 'cap-override' => 'TEXT',
'condense-whitespace' => 'INTEGER',
'created_on' => 'NUMERIC', 'created_on' => 'NUMERIC',
'dont-protect-self' => 'INTEGER', 'dont-protect-self' => 'INTEGER',
'dont-replace-pronouns' => 'INTEGER', 'dont-replace-pronouns' => 'INTEGER',
@ -39,7 +40,6 @@ our %factoid_metadata = (
'nooverride' => 'INTEGER', 'nooverride' => 'INTEGER',
'owner' => 'TEXT', 'owner' => 'TEXT',
'persist-key' => 'INTEGER', 'persist-key' => 'INTEGER',
'preserve_whitespace' => 'INTEGER',
'process-timeout' => 'INTEGER', 'process-timeout' => 'INTEGER',
'rate_limit' => 'INTEGER', 'rate_limit' => 'INTEGER',
'ref_count' => 'INTEGER', 'ref_count' => 'INTEGER',

View File

@ -239,9 +239,9 @@ sub interpreter($self, $context) {
$context->{use_output_queue} = 1; $context->{use_output_queue} = 1;
} }
# turn on context->{preserve_whitespace}? # turn on context->{condense-whitespace}?
if ($self->{pbot}->{factoids}->{data}->{storage}->get_data($channel, $keyword, 'preserve_whitespace')) { if ($self->{pbot}->{factoids}->{data}->{storage}->get_data($channel, $keyword, 'condense-whitespace')) {
$context->{preserve_whitespace} = 1; $context->{'condense-whitespace'} = 1;
} }
# tell PBot::Core::Interpreter to prepend caller's nick to output # tell PBot::Core::Interpreter to prepend caller's nick to output
@ -442,10 +442,10 @@ sub handle_action($self, $context, $action) {
} }
} }
my $preserve_whitespace = $self->{pbot}->{factoids}->{data}->{storage}->get_data($channel, $keyword, 'preserve_whitespace'); my $condense_whitespace = $self->{pbot}->{factoids}->{data}->{storage}->get_data($channel, $keyword, 'condense-whitespace');
if (defined $preserve_whitespace) { if (defined $condense_whitespace) {
$context->{preserve_whitespace} = $preserve_whitespace; $context->{'condense-whitespace'} = $condense_whitespace;
} }
# action is a code factoid # action is a code factoid

View File

@ -585,8 +585,8 @@ sub interpret($self, $context) {
# sends final command output to appropriate queues. # sends final command output to appropriate queues.
# use context result if no result argument given. # use context result if no result argument given.
sub handle_result($self, $context, $result = $context->{result}) { sub handle_result($self, $context, $result = $context->{result}) {
# preservation of consecutive whitespace is disabled by default # condensation of consecutive whitespace is disable by default
$context->{preserve_whitespace} //= 0; $context->{'condense-whitespace'} //= 0;
# debug flag to trace $context location and contents # debug flag to trace $context location and contents
if ($self->{pbot}->{registry}->get_value('general', 'debugcontext')) { if ($self->{pbot}->{registry}->get_value('general', 'debugcontext')) {
@ -707,7 +707,7 @@ sub handle_result($self, $context, $result = $context->{result}) {
$context->{original_result} = $result; $context->{original_result} = $result;
$result =~ s/[\n\r]/ /g unless $preserve_newlines; $result =~ s/[\n\r]/ /g unless $preserve_newlines;
#$result =~ s/[ \t]+/ /g unless $context->{preserve_whitespace}; $result =~ s/[ \t]+/ /g if $context->{'condense-whitespace'};
my $max_lines = $self->{pbot}->{registry}->get_value($context->{from}, 'max_newlines') // 4; my $max_lines = $self->{pbot}->{registry}->get_value($context->{from}, 'max_newlines') // 4;
my $lines = 0; my $lines = 0;
@ -999,7 +999,6 @@ sub add_to_command_queue($self, $channel, $command, $delay = 0, $repeating = 0)
command => $command->{command}, command => $command->{command},
interpret_depth => 0, interpret_depth => 0,
checkflood => 0, checkflood => 0,
preserve_whitespace => 0
}; };
if (exists $command->{'cap-override'}) { if (exists $command->{'cap-override'}) {
@ -1311,7 +1310,7 @@ sub split_line($self, $line, %opts) {
} }
unless ($opts{strip_commas} and $token eq ',') { unless ($opts{strip_commas} and $token eq ',') {
$add_token = 1 if $got_ch;; $add_token = 1 if $got_ch;
} }
next; next;
} }

View File

@ -25,7 +25,7 @@ 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 => 4831, BUILD_REVISION => 4833,
BUILD_DATE => "2024-11-03", BUILD_DATE => "2024-11-03",
}; };

View File

@ -43,6 +43,7 @@ my %factoid_metadata = (
'allow_empty_args' => 'INTEGER', 'allow_empty_args' => 'INTEGER',
'background-process' => 'INTEGER', 'background-process' => 'INTEGER',
'cap-override' => 'TEXT', 'cap-override' => 'TEXT',
'condense-whitespace' => 'INTEGER',
'created_on' => 'NUMERIC', 'created_on' => 'NUMERIC',
'dont-protect-self' => 'INTEGER', 'dont-protect-self' => 'INTEGER',
'dont-replace-pronouns' => 'INTEGER', 'dont-replace-pronouns' => 'INTEGER',
@ -61,7 +62,6 @@ my %factoid_metadata = (
'nooverride' => 'INTEGER', 'nooverride' => 'INTEGER',
'owner' => 'TEXT', 'owner' => 'TEXT',
'persist-key' => 'INTEGER', 'persist-key' => 'INTEGER',
'preserve_whitespace' => 'INTEGER',
'process-timeout' => 'INTEGER', 'process-timeout' => 'INTEGER',
'rate_limit' => 'INTEGER', 'rate_limit' => 'INTEGER',
'ref_count' => 'INTEGER', 'ref_count' => 'INTEGER',