mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-22 18:52:40 +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:
parent
41c5182208
commit
9ebc77f4da
9
data/commands
vendored
9
data/commands
vendored
@ -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" : {
|
||||
|
BIN
data/factoids.sqlite3
vendored
BIN
data/factoids.sqlite3
vendored
Binary file not shown.
@ -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.
|
||||
`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
|
||||
|
14
doc/FAQ.md
14
doc/FAQ.md
@ -86,18 +86,18 @@ For example:
|
||||
<PBot> a
|
||||
<PBot> b
|
||||
<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?
|
||||
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.
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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}) {
|
||||
|
@ -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',
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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",
|
||||
};
|
||||
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user