diff --git a/data/commands b/data/commands index 85387f08..49c16d4b 100644 --- a/data/commands +++ b/data/commands @@ -191,7 +191,7 @@ }, "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" : { "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" }, "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", "requires_cap" : "0" }, @@ -353,13 +354,11 @@ "plang" : { "dont-replace-pronouns" : "1", "help" : "", - "preserve_whitespace" : "1", "requires_cap" : "0" }, "plangrepl" : { "dont-replace-pronouns" : "1", "help" : "", - "preserve_whitespace" : "1", "requires_cap" : 0 }, "plug" : { @@ -381,6 +380,7 @@ "recall" : { "dont-replace-pronouns" : "0", "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" }, "refresh" : { @@ -397,7 +397,7 @@ }, "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" : { "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" : { "help" : "Wordle game! Guess target word by submitting words for clues about which letters belong to the word!", - "preserve_whitespace" : "1", "requires_cap" : null }, "wordmorph" : { diff --git a/data/factoids.sqlite3 b/data/factoids.sqlite3 index 490ab847..d87d2aef 100644 Binary files a/data/factoids.sqlite3 and b/data/factoids.sqlite3 differ diff --git a/doc/Admin.md b/doc/Admin.md index 57e6e88e..a051add9 100644 --- a/doc/Admin.md +++ b/doc/Admin.md @@ -620,7 +620,7 @@ Name | Description `cap-required` | When set to a true value then the command requires that users have the `can-` [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. `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. ## Event-queue management diff --git a/doc/FAQ.md b/doc/FAQ.md index 89e58840..9244df78 100644 --- a/doc/FAQ.md +++ b/doc/FAQ.md @@ -86,18 +86,18 @@ For example: a b c - And that's all I have to say about that. See https://0x0.st/-Okb.txt for full text. + -## I made a command. It's supposed to output formatting with spaces and tabs? -By default, PBot collapses adjacent whitespace in command output. This is intended to -reduce visual noise in IRC channels. +## How can I remove excessive spaces and tabs from command output? +If a command or factoid is producing too much whitespace and making it +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 -to set the `preserve_whitespace` [command metadata](Admin.md#command-metadata-list) to -control this behavior. +to set the `condense-whitespace` [command metadata](Admin.md#command-metadata-list). 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? If you have a NickServ account or a unique hostmask, you don't need a PBot password. diff --git a/doc/Factoids.md b/doc/Factoids.md index 03cd0106..734820d3 100644 --- a/doc/Factoids.md +++ b/doc/Factoids.md @@ -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. `allow_empty_args` | none | Do not replace empty arguments with `$nick`. `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 ### factfind diff --git a/lib/PBot/Core/Commands.pm b/lib/PBot/Core/Commands.pm index c1934d1a..9c614a48 100644 --- a/lib/PBot/Core/Commands.pm +++ b/lib/PBot/Core/Commands.pm @@ -194,8 +194,8 @@ sub interpreter($self, $context) { } } - if ($self->get_meta($keyword, 'preserve_whitespace')) { - $context->{preserve_whitespace} = 1; + if ($self->get_meta($keyword, 'condense-whitespace')) { + $context->{'condense-whitespace'} = 1; } # tell PBot::Core::Interpreter to prepend caller's nick to output diff --git a/lib/PBot/Core/Commands/Factoids.pm b/lib/PBot/Core/Commands/Factoids.pm index 86aca51d..ca737fb1 100644 --- a/lib/PBot/Core/Commands/Factoids.pm +++ b/lib/PBot/Core/Commands/Factoids.pm @@ -982,8 +982,6 @@ sub cmd_factshow($self, $context) { my $factoids = $self->{pbot}->{factoids}->{data}->{storage}; - $context->{preserve_whitespace} = 1; - my ($chan, $trig) = @$opt_args; $chan = $context->{from} if not defined $trig; 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 ($channel, $trigger, $keyword, $delim, $tochange, $changeto, $modifier, $url); - $context->{preserve_whitespace} = 1; - my $needs_disambig; if (length $context->{arguments}) { diff --git a/lib/PBot/Core/Factoids/Data.pm b/lib/PBot/Core/Factoids/Data.pm index 6a08cc68..b29374d7 100644 --- a/lib/PBot/Core/Factoids/Data.pm +++ b/lib/PBot/Core/Factoids/Data.pm @@ -19,6 +19,7 @@ our %factoid_metadata = ( 'allow_empty_args' => 'INTEGER', 'background-process' => 'INTEGER', 'cap-override' => 'TEXT', + 'condense-whitespace' => 'INTEGER', 'created_on' => 'NUMERIC', 'dont-protect-self' => 'INTEGER', 'dont-replace-pronouns' => 'INTEGER', @@ -39,7 +40,6 @@ our %factoid_metadata = ( 'nooverride' => 'INTEGER', 'owner' => 'TEXT', 'persist-key' => 'INTEGER', - 'preserve_whitespace' => 'INTEGER', 'process-timeout' => 'INTEGER', 'rate_limit' => 'INTEGER', 'ref_count' => 'INTEGER', diff --git a/lib/PBot/Core/Factoids/Interpreter.pm b/lib/PBot/Core/Factoids/Interpreter.pm index 75b7aed7..8a574f70 100644 --- a/lib/PBot/Core/Factoids/Interpreter.pm +++ b/lib/PBot/Core/Factoids/Interpreter.pm @@ -239,9 +239,9 @@ sub interpreter($self, $context) { $context->{use_output_queue} = 1; } - # turn on context->{preserve_whitespace}? - if ($self->{pbot}->{factoids}->{data}->{storage}->get_data($channel, $keyword, 'preserve_whitespace')) { - $context->{preserve_whitespace} = 1; + # turn on context->{condense-whitespace}? + if ($self->{pbot}->{factoids}->{data}->{storage}->get_data($channel, $keyword, 'condense-whitespace')) { + $context->{'condense-whitespace'} = 1; } # 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) { - $context->{preserve_whitespace} = $preserve_whitespace; + if (defined $condense_whitespace) { + $context->{'condense-whitespace'} = $condense_whitespace; } # action is a code factoid diff --git a/lib/PBot/Core/Interpreter.pm b/lib/PBot/Core/Interpreter.pm index 03593bff..20d1eaf8 100644 --- a/lib/PBot/Core/Interpreter.pm +++ b/lib/PBot/Core/Interpreter.pm @@ -585,8 +585,8 @@ sub interpret($self, $context) { # sends final command output to appropriate queues. # use context result if no result argument given. sub handle_result($self, $context, $result = $context->{result}) { - # preservation of consecutive whitespace is disabled by default - $context->{preserve_whitespace} //= 0; + # condensation of consecutive whitespace is disable by default + $context->{'condense-whitespace'} //= 0; # debug flag to trace $context location and contents if ($self->{pbot}->{registry}->get_value('general', 'debugcontext')) { @@ -707,7 +707,7 @@ sub handle_result($self, $context, $result = $context->{result}) { $context->{original_result} = $result; $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 $lines = 0; @@ -999,7 +999,6 @@ sub add_to_command_queue($self, $channel, $command, $delay = 0, $repeating = 0) command => $command->{command}, interpret_depth => 0, checkflood => 0, - preserve_whitespace => 0 }; if (exists $command->{'cap-override'}) { @@ -1311,7 +1310,7 @@ sub split_line($self, $line, %opts) { } unless ($opts{strip_commas} and $token eq ',') { - $add_token = 1 if $got_ch;; + $add_token = 1 if $got_ch; } next; } diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index a67adf9d..2a23940c 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,7 +25,7 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4831, + BUILD_REVISION => 4833, BUILD_DATE => "2024-11-03", }; diff --git a/misc/greybot/import-greybot.pl b/misc/greybot/import-greybot.pl index e509f81f..ce503134 100755 --- a/misc/greybot/import-greybot.pl +++ b/misc/greybot/import-greybot.pl @@ -43,6 +43,7 @@ my %factoid_metadata = ( 'allow_empty_args' => 'INTEGER', 'background-process' => 'INTEGER', 'cap-override' => 'TEXT', + 'condense-whitespace' => 'INTEGER', 'created_on' => 'NUMERIC', 'dont-protect-self' => 'INTEGER', 'dont-replace-pronouns' => 'INTEGER', @@ -61,7 +62,6 @@ my %factoid_metadata = ( 'nooverride' => 'INTEGER', 'owner' => 'TEXT', 'persist-key' => 'INTEGER', - 'preserve_whitespace' => 'INTEGER', 'process-timeout' => 'INTEGER', 'rate_limit' => 'INTEGER', 'ref_count' => 'INTEGER',