This PR adds support for constraining PoshBot to certain channels and also controlling what plugin commands are allowed in said channels.
This also fixed a bug where the approval configuration settings where not being saved to the bot config file correctly.
There is a new bot configuration property called ChannelRules that is a hashtable[] to control what commands are included and excluded from channels(s). Wild cards are supported so multiple channels can be covered by a single "rule". The rules are evaluated in order so the most specific ones should be added first.
The fully qualified command name :: is what is evaluated so the rule examples below are supported.
"all commands in plugin A"
"version 1.2.3 of plugin X"
"only command Y of plugin Z"
Example bot.psd1
@{
ChannelRules= @(
# Only builtin and admin plugin commands allowed in the admin channel
@{
Channel = 'admin'
IncludeCommands = @(
'builtin:*'
'myadminplugin:*'
)
}
# It's the wild west in random, except giphy :)
@{
Channel = 'random'
IncludeCommands = @('*')
ExcludeCommands = @('*giphy*')
}
# Exclude builtin commands from any "projectX" channel
@{
Channel = '*projectx*'
IncludeCommands = @('*')
ExcludeCommands = @('builtin:*')
}
# All commands are otherwise allowed
@{
Channel = '*'
IncludeCommands = @('*')
ExcludeCommands = @()
}
)
}
Related Issue
36
Motivation and Context
See #36
How Has This Been Tested?
Manually tested new functionality
Types of changes
[X] Bug fix (non-breaking change which fixes an issue)
[X] New feature (non-breaking change which adds functionality)
[X] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
[X] My code follows the code style of this project.
[X] My change requires a change to the documentation.
Description
This PR adds support for constraining PoshBot to certain channels and also controlling what plugin commands are allowed in said channels.
This also fixed a bug where the approval configuration settings where not being saved to the bot config file correctly.
There is a new bot configuration property called ChannelRules that is a
hashtable[]
to control what commands are included and excluded from channels(s). Wild cards are supported so multiple channels can be covered by a single "rule". The rules are evaluated in order so the most specific ones should be added first.The fully qualified command name:: is what is evaluated so the rule examples below are supported.
Example bot.psd1
Related Issue
36
Motivation and Context
See #36
How Has This Been Tested?
Manually tested new functionality
Types of changes
Checklist: