mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-17 01:19:31 +01:00
Factoids: require locked
to be exactly 1
to invoke commands with required_caps
This allows us to set `locked` to a value greater than `1` to lock a factoid WITHOUT allowing invocation of `required_caps` commands. This lets us safely lock a factoid that has unrestrained `$args` or variables.
This commit is contained in:
parent
12ec8bb77c
commit
a262139fd2
@ -59,7 +59,7 @@
|
|||||||
<!-- md-toc-end -->
|
<!-- md-toc-end -->
|
||||||
|
|
||||||
## About
|
## About
|
||||||
Factoids are a very special type of command. Anybody interacting with PBot can create, edit, delete and invoke factoids. Factoids can be locked by the creator of the factoid to prevent them from being edited by others.
|
Factoids are a very special type of command. Anybody interacting with PBot can create, edit, delete and invoke factoids.
|
||||||
|
|
||||||
At its most simple, a factoid merely displays the text the creator sets.
|
At its most simple, a factoid merely displays the text the creator sets.
|
||||||
|
|
||||||
@ -622,7 +622,7 @@ Name | Capability | Description
|
|||||||
`type` | botowner | The type of the factoid. "text" for regular factoid; "module" for module.
|
`type` | botowner | The type of the factoid. "text" for regular factoid; "module" for module.
|
||||||
`edited_by` | botowner | The hostmask of the person to last edit the factoid.
|
`edited_by` | botowner | The hostmask of the person to last edit the factoid.
|
||||||
`edited_on` | botowner | The timestamp of when the factoid was last edited.
|
`edited_on` | botowner | The timestamp of when the factoid was last edited.
|
||||||
`locked` | chanop | If enabled, prevents the factoid from being changed or removed.
|
`locked` | chanop | If enabled, prevents the factoid from being changed or removed. Must be set to `1` to allow factoid to invoke a command that has `required_caps` enabled. Can be set to a value greater than `1` to lock the factoid without allowing `required_caps` commands to be invoked.
|
||||||
`add_nick` | chanop | Prepends the nick of the person invoking the factoid to the output of the factoid.
|
`add_nick` | chanop | Prepends the nick of the person invoking the factoid to the output of the factoid.
|
||||||
`nooverride` | chanop | Prevents the creation of a factoid with an identical name in a different channel.
|
`nooverride` | chanop | Prevents the creation of a factoid with an identical name in a different channel.
|
||||||
`cap-override` | botowner | Provides a user with the capability specified, just for this factoid invocation.
|
`cap-override` | botowner | Provides a user with the capability specified, just for this factoid invocation.
|
||||||
|
@ -193,8 +193,8 @@ sub interpreter($self, $context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($context->{factoid} && !$context->{locked}) {
|
if ($context->{factoid} && $context->{locked} != 1) {
|
||||||
return "/msg $context->{nick} The $keyword command requires the can-$keyword capability and cannot be invoked from an unlocked factoid.";
|
return "/msg $context->{nick} The $keyword command requires the can-$keyword capability and cannot be invoked from a factoid that does not have `locked` set to 1.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,11 +195,7 @@ sub interpreter($self, $context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($self->{pbot}->{factoids}->{data}->{storage}->get_data($channel, $keyword, 'locked')) {
|
$context->{locked} = $self->{pbot}->{factoids}->{data}->{storage}->get_data($channel, $keyword, 'locked') // 0;
|
||||||
$context->{locked} = 1;
|
|
||||||
} else {
|
|
||||||
$context->{locked} = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
# rate-limiting
|
# rate-limiting
|
||||||
if ($context->{interpret_depth} <= 1
|
if ($context->{interpret_depth} <= 1
|
||||||
|
@ -25,8 +25,8 @@ 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 => 4840,
|
BUILD_REVISION => 4841,
|
||||||
BUILD_DATE => "2024-11-06",
|
BUILD_DATE => "2024-11-07",
|
||||||
};
|
};
|
||||||
|
|
||||||
sub initialize {}
|
sub initialize {}
|
||||||
|
Loading…
Reference in New Issue
Block a user