poshbotio / PoshBot

Powershell-based bot framework
MIT License
538 stars 108 forks source link

Add builtin command to create a new permission and associate with existing commands #5

Closed devblackops closed 7 years ago

devblackops commented 7 years ago

Expected Behavior

New builtin commands should be added to create permissions and to associate those permissions to existing commands.

Current Behavior

These commands do not exist

Possible Solution

Proposed commands

Create a new permission associated with a plugin

New-Permission --name <pluginname:permissionname> --description 'my description'

Associate a permission with a plugin command

Add-CommandPermission --command <pluginname:commandname> --permission <pluginname:permissionname>

The current plugin and permission state that is saved to local storage will have to be extended to allow these adhoc permissions to be saved permanently. The current logic that loads plugins on startup will also have to be modified to merge in these permissions that aren't included with the module manifest.

Context

There will probably be cases where a 3rd party plugin is installed that does not include permissions, or the permissions included do not satisfy the bot administrator's needs.

joshuatee commented 7 years ago

How about a default "Everyone" group that gets populated with new users joining a team/channel?

devblackops commented 7 years ago

By not specifying a permission on a command, that command is available to everyone. Would there be a need for an Everyone group is that case?

joshuatee commented 7 years ago

I guess it was a silly idea. I was trying to figure out how to provide help only for the commands in my module while using the builtin 'help' command.

devblackops commented 7 years ago

Not silly at all. This project is in it's early stages and most of the documentation has yet to be written. If anything is unclear it helps to have it called out so it can be prioritized.

The help command should list all commands for all loaded plugins. All exported functions from any vanilla PowerShell module loaded into PoshBot should show up in help automatically and since those plugins (PS modules) don't include any PoshBot specific information, the commands will be available to everybody.

The [PoshBot.BotCommand()] attribute is only needed when you wish to attach permissions to the command or change it's behavior in some way.

Those scenarios would be renaming the command to something other than the function name, having the command be executed in response to a regex expression being matched, a specific event (other than a message) being returned from the chat network, and a few other things.