Giter Site home page Giter Site logo

poshbot's People

Contributors

adrian-andersson avatar andrewpla avatar angleosaxon avatar brettmillerb avatar chriswahl avatar devblackops avatar dreznicek avatar dwof avatar jaapbrasser avatar jamesbr-ashn avatar jasonnoonan avatar joakimkarlbom avatar joshuatee avatar markwragg avatar megamorf avatar michaeltlombardi avatar phdavis avatar pilosite avatar ramblingcookiemonster avatar rayterrill avatar scrthq avatar szeraax avatar tadas avatar windos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

poshbot's Issues

Potential feature: Allow mechanism for aliasing commands

It appears we can currently specify one CommandName in a PoshBot attribute. It might be helpful to allow specifying an array, to allow some alias-esque system, or any other means to allow an author to map multiple poshbot command names to a single actual command.

Example: I might have Get-ADUser as the CommandName, with a shortcut gu or qu that would end up invoking the same PowerShell command under the hood. Some folks don't like to type : )

Cheers!

Documentation Transition

This project's documentation is somewhat limited and spread across a few markdown files and the wiki. I suggest you migrate towards a documentation solution using either MkDocs or GitBook.

Expected Behavior

Users should be able to access a documentation site for the project which includes tutorials, design explanations/concept guides, and reference materials. Preferably, this documentation should be versioned, available as a downloadable artifact, source controlled, and built automatically via CI.

Current Behavior

Documentation exists in limited form as both markdown documents in the main repository as well as wiki articles in the project.

Possible Solution

We could use either MkDocs or GitBook to create the documentation site. GitBook can also be used to export to PDF/epub/mobi format for artifact download.

I suggest breaking documentation into three broad parts:

  1. Tutorials: This section includes more blog-like documentation conversationally walking prospective users/developers through using and interacting with the project. This is a perfect place to give an example of how to create a plugin or how to set permissions for a role.
  2. Guides: This section is more like an informal set of white papers or design documents explaining design decisions, security concerns, and other topics not best suited to a blog format but which still need to be covered.
  3. Reference: This section is where all of the actual reference documentation (exported comment based help, class references, etc) belong.

Context

I have found that this type of documentation makes using a project much easier from both a normal user standpoint as well as from a contributing developer standpoint. It doesn't have to be written all at once but providing a base level of useful documentation and then iterating on it can help to drive adoption and help answer questions about the project more easily.

a n00b's corner

what went wrong?

$backend = New-PoshBotSlackBackend -Configuration @{Name = 'SlackBackend'; Token =
'SLACK-API-TOKEN'}
$pbc = New-PoshBotConfiguration -BackendConfiguration $backend

New-PoshBotConfiguration : Cannot process argument transformation on parameter 'BackendConfiguration'. Cannot convert
the "SlackBackend" value of type "SlackBackend" to type "System.Collections.Hashtable". 

I tend to get those 'xxx values of type xxx' way too often

Consider constraining bot functionality by channel

It might be worth considering functionality to restrict bot, plugin, or command functionality by channel.

Hypothetical scenario: You provide a command that retrieves potentially sensitive information. You have certain channels with team members (or guest accounts) who should not see this information. Currently, a valid user may invite poshbot, and run a command that exposes this information in one of those channels.

If controls were in place, you could solve this various ways:

  • No bot needed in a channel? Configure poshbot itself to only respond in whitelisted channels
  • Bot needed, but entire plugin is sensitive? Configure plugin-to-channel access controls
  • Bot needed, and certain commands from a plugin needed, others need to be restricted? Configure command-to-channel access controls

These could likely be configured in a similar way to user access for the latter two, and via poshbot configs themselves for the bot-level controls.

Not something we personally need at the moment, just thinking of scenarios that might come up down the road

New Builtin Function: Update-Plugin

Users should be able to run a command to update one or more plugins used by the bot.

Expected Behavior

Users should have access to a builtin command, Update-Plugin, which can update one plugin, several plugins, or all plugins to their latest versions and reload those plugins after the update. It should be able to update to the latest locally available version as well as search remote PowerShell repositories for newer versions.

Current Behavior

This functionality does not exist.

Possible Solution

Create the new function in the Builtin plugin.

Context

Very often will people want to update existing plugins used by the bot; this should be easy and obvious. This is even more useful for people contributing/developing since their versions will likely change more rapidly.

Your Environment

  • Module version used: 1.0
  • Operating System and PowerShell version: W10, 5.1

Create Mattermost backend

We use Mattermost (an open source slack alternative) in our company and since it tries to be API-compatible with slack the work on the backend should be manageable.

Can we have a chat on Gitter/slack to discuss the technical implementation of the current slack backend?

Thanks in advance ;-)

Command exception when installing a plugin

Expected Behavior

The plugin (module) is installed without error

Current Behavior

When running !install-plugin --name <pluginname>, the command throws the exception below. This appears to be an innocuous error as the plugin is installed fine. Running !get-plugin --plugin <pluginname> shows the newly installed plugin and executing the plugin commands work correctly.

Command Exception:
System.Management.Automation.StopUpstreamCommandsException: System error.
   at Microsoft.PowerShell.Commands.SelectObjectCommand.ProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()

Steps to Reproduce (for bugs)

Run the following command to install a plugin (module) from the PSGallery

!install-plugin --name nameit

GetEnumeration error when starting bot instance on NanoServer

Expected Behavior

Bot starts when you run $bot.start() on NanoServer.

Current Behavior

Bot start is interrupted by GetEnumerator error on NanoServer.

PS C:\> $bot.start()
Cannot find an overload for "GetEnumerator" and the argument count: "0".
At line:1 char:1
+ $bot.start()
+ ~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException

PS C:\> $bot | Start-PoshBot -Verbose -Debug
VERBOSE: [SlackBackend:LoadUsers] Adding user: U4ZLZE6E9:megamorf
VERBOSE: [SlackBackend:LoadUsers] Adding user: U4ZGBQQDR:poshbotdockertest
VERBOSE: [SlackBackend:LoadUsers] Adding user: USLACKBOT:slackbot
VERBOSE: [SlackBackend:LoadRooms] Adding channel: C5091LHFZ:general
VERBOSE: [SlackBackend:LoadRooms] Adding channel: C4ZGB5HJ7:random
VERBOSE: [Group: AddUser] User [U4ZLZE6E9] is already in [Admin]
DEBUG: [SlackBackend:ReceiveMessage] Received
{"type":"message","channel":"C4ZGB5HJ7","user":"U4ZLZE6E9","text":"!help","ts":"1492244031.722558","source_team":"T4ZGB5E9Z","team":"T4ZGB5E9Z"}

Confirm
Continue with this operation?
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): a
Cannot find an overload for "GetEnumerator" and the argument count: "0".
At line:1 char:1
+ $bot | start-poshbot -Verbose -Debug
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException


PS C:\> Resolve-Error


writeErrorStream      : True
PSMessageDetails      :
Exception             : Microsoft.PowerShell.Commands.WriteErrorException: Cannot find an overload for "GetEnumerator" and the argument count: "0".
TargetObject          :
CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at Start, C:\Program Files\WindowsPowerShell\Modules\poshbot\0.2.1\PoshBot.psm1: line 2522
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}




MyCommand             :
BoundParameters       : {}
UnboundArguments      : {}
ScriptLineNumber      : 1
OffsetInLine          : 1
HistoryId             : 17
ScriptName            :
Line                  : $bot.start()
PositionMessage       : At line:1 char:1
                        + $bot.start()
                        + ~~~~~~~~~~~~
PSScriptRoot          :
PSCommandPath         :
InvocationName        :
PipelineLength        : 0
PipelinePosition      : 0
ExpectingInput        : False
CommandOrigin         : Internal
DisplayScriptPosition :



00000000000000000000000000000000000000000000000000000000000000000000000000000000


Message        : Cannot find an overload for "GetEnumerator" and the argument count: "0".
Data           : {}
InnerException :
StackTrace     :
HelpLink       :
Source         :
HResult        : -2146233088

Possible Solution

None.

Steps to Reproduce (for bugs)

  1. Install-Module -Name PoshBot -Repository PSGallery
  2. Generate new config with New-PoshBotConfiguration and save to file with Save-PoshBotConfiguration:
@{
  AlternateCommandPrefixes = @('poshbot')
  PluginRepository = @('PSGallery')
  LogDirectory = 'C:\Users\ContainerAdministrator\.poshbot'
  Name = 'poshbotdockertest'
  BotAdmins = @('megamorf')
  ConfigurationDirectory = 'C:\Users\ContainerAdministrator\.poshbot'
  BackendConfiguration = @{
    Token = 'xoxb-169555840467-vh3I4ex91hIZVBiGqy7Xpxxx'
    Name = 'SlackBackend'
  }
  LogLevel = 'Verbose'
  PluginDirectory = 'C:\Users\ContainerAdministrator\.poshbot'
  MuteUnknownCommand = $False
  ModuleManifestsToLoad = @()
  AlternateCommandPrefixSeperators = @(':',',',';')
  SendCommandResponseToPrivate = @()
  PluginConfiguration = @{

  }
  CommandPrefix = '!'
}
  1. Follow steps from docs:
$pbc = Get-PoshBotConfiguration -Path .\poshbot.psd1
$backend = New-PoshBotSlackBackend -Configuration $pbc.BackendConfiguration
$bot = New-PoshBotInstance -Configuration $pbc -Backend $backend
$bot.start()
  1. Get error

Context

The issue prevents me from testing PoshBot on NanoServer.

Your Environment

PS C:\> $PSVersionTable

Name                           Value
----                           -----
WSManStackVersion              3.0
PSVersion                      5.1.14393.1000
CLRVersion
PSEdition                      Core
BuildVersion                   10.0.14393.1000
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.3

PS C:\> Get-Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.0.2      Configuration                       {Add-MetadataConverter, ConsoleColor, ConvertFrom-Metadata, ConvertTo-Me...
Manifest   7.0.1      Json.Net
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty...}
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-Authenti...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Binary     1.0.0.1    PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider...}
Script     0.2.1      poshbot                             {Get-PoshBot, Get-PoshBotConfiguration, New-PoshBotCardResponse, New-Pos...
Script     0.0        PoshBotAttribute
Script     1.0.0.1    PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability...}
Script     0.0.17     PSSlack                             {Find-SlackMessage, Get-PSSlackConfig, Get-SlackChannel, Get-SlackGroup...}

New-PoshBotInstance throws error on Nanoserver

Expected Behavior

Be able to create poshbot instance with New-PoshBotInstance function on NanoServer (in docker container)

Current Behavior

Throws runtime expection due to a null value in the if ($_.TypeId.ToString() -eq 'PoshBot.BotCommand') {check.

See detailed error info below

PS C:\> Resolve-Error


PSMessageDetails      :
Exception             : System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression.
                           at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
                           at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
                           at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                           at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                           at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
                           at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
                           at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean createLocalScope, Dictionary`2 functionsToDefine, List`1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object
                        dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args)
                           at System.Management.Automation.ScriptBlock.<>c__DisplayClass57_0.<InvokeWithPipe>b__0()
                           at System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(Action action)
                           at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean
                        propagateAllExceptionsToTop, List`1 variablesToDefine, Dictionary`2 functionsToDefine, Object[] args)
                           at System.Management.Automation.ScriptBlock.InvokeUsingCmdlet(Cmdlet contextCmdlet, Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Object[] args)
                           at Microsoft.PowerShell.Commands.ForEachObjectCommand.ProcessRecord()
                           at System.Management.Automation.Cmdlet.DoProcessRecord()
                           at System.Management.Automation.CommandProcessor.ProcessRecord()
TargetObject          :
CategoryInfo          : InvalidOperation: (:) [], RuntimeException
FullyQualifiedErrorId : InvokeMethodOnNull
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, C:\Program Files\WindowsPowerShell\Modules\PoshBot\0.2.0\PoshBot.psm1: line 2197
                        at GetCommandMetadata, C:\Program Files\WindowsPowerShell\Modules\PoshBot\0.2.0\PoshBot.psm1: line 2196
                        at CreatePluginFromModuleManifest, C:\Program Files\WindowsPowerShell\Modules\PoshBot\0.2.0\PoshBot.psm1: line 2088
                        at LoadBuiltinPlugins, C:\Program Files\WindowsPowerShell\Modules\PoshBot\0.2.0\PoshBot.psm1: line 2230
                        at Initialize, C:\Program Files\WindowsPowerShell\Modules\PoshBot\0.2.0\PoshBot.psm1: line 1692
                        at PluginManager, C:\Program Files\WindowsPowerShell\Modules\PoshBot\0.2.0\PoshBot.psm1: line 1685
                        at Initialize, C:\Program Files\WindowsPowerShell\Modules\PoshBot\0.2.0\PoshBot.psm1: line 2438
                        at Bot, C:\Program Files\WindowsPowerShell\Modules\PoshBot\0.2.0\PoshBot.psm1: line 2418
                        at New-PoshBotInstance<Process>, C:\Program Files\WindowsPowerShell\Modules\PoshBot\0.2.0\PoshBot.psm1: line 3828
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}





MyCommand             :
BoundParameters       : {}
UnboundArguments      : {}
ScriptLineNumber      : 2197
OffsetInLine          : 17
HistoryId             : -1
ScriptName            : C:\Program Files\WindowsPowerShell\Modules\PoshBot\0.2.0\PoshBot.psm1
Line                  :             if ($_.TypeId.ToString() -eq 'PoshBot.BotCommand') {

PositionMessage       : At C:\Program Files\WindowsPowerShell\Modules\PoshBot\0.2.0\PoshBot.psm1:2197 char:17
                        +             if ($_.TypeId.ToString() -eq 'PoshBot.BotCommand') {
                        +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot          : C:\Program Files\WindowsPowerShell\Modules\PoshBot\0.2.0
PSCommandPath         : C:\Program Files\WindowsPowerShell\Modules\PoshBot\0.2.0\PoshBot.psm1
InvocationName        :
PipelineLength        : 0
PipelinePosition      : 0
ExpectingInput        : False
CommandOrigin         : Internal
DisplayScriptPosition :



00000000000000000000000000000000000000000000000000000000000000000000000000000000


ErrorRecord                 : You cannot call a method on a null-valued expression.
WasThrownFromThrowStatement : False
Message                     : You cannot call a method on a null-valued expression.
Data                        : {System.Management.Automation.Interpreter.InterpretedFrameInfo}
InnerException              :
StackTrace                  :    at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
                                 at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
                                 at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                                 at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                                 at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
                                 at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
                                 at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean createLocalScope, Dictionary`2 functionsToDefine, List`1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior,
                              Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args)
                                 at System.Management.Automation.ScriptBlock.<>c__DisplayClass57_0.<InvokeWithPipe>b__0()
                                 at System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(Action action)
                                 at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean
                              propagateAllExceptionsToTop, List`1 variablesToDefine, Dictionary`2 functionsToDefine, Object[] args)
                                 at System.Management.Automation.ScriptBlock.InvokeUsingCmdlet(Cmdlet contextCmdlet, Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Object[] args)
                                 at Microsoft.PowerShell.Commands.ForEachObjectCommand.ProcessRecord()
                                 at System.Management.Automation.Cmdlet.DoProcessRecord()
                                 at System.Management.Automation.CommandProcessor.ProcessRecord()
HelpLink                    :
Source                      : System.Management.Automation
HResult                     : -2146233088

Possible Solution

None.

Steps to Reproduce (for bugs)

  1. Install-Module -Name PoshBot -Repository PSGallery
  2. Generate new config with New-PoshBotConfiguration and save to file with Save-PoshBotConfiguration:
@{
  AlternateCommandPrefixes = @('poshbot')
  PluginRepository = @('PSGallery')
  LogDirectory = 'C:\Users\ContainerAdministrator\.poshbot'
  Name = 'poshbotdockertest'
  BotAdmins = @('megamorf')
  ConfigurationDirectory = 'C:\Users\ContainerAdministrator\.poshbot'
  BackendConfiguration = @{
    Token = 'xoxb-169555840467-vh3I4ex91hIZVBiGqy7Xpxxx'
    Name = 'SlackBackend'
  }
  LogLevel = 'Verbose'
  PluginDirectory = 'C:\Users\ContainerAdministrator\.poshbot'
  MuteUnknownCommand = $False
  ModuleManifestsToLoad = @()
  AlternateCommandPrefixSeperators = @(':',',',';')
  SendCommandResponseToPrivate = @()
  PluginConfiguration = @{

  }
  CommandPrefix = '!'
}
  1. Follow steps from docs:
$pbc = Get-PoshBotConfiguration -Path .\poshbot.psd1
$backend = New-PoshBotSlackBackend -Configuration $pbc.BackendConfiguration
$bot = New-PoshBotInstance -Configuration $pbc -Backend $backend
  1. Get error

Context

The issue prevents me from testing PoshBot on NanoServer.

Your Environment

PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSEdition                      Core
CLRVersion
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
PSVersion                      5.1.14393.1000
BuildVersion                   10.0.14393.1000
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS C:\> get-module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.0.2      Configuration                       {Add-MetadataConverter, ConsoleColor, ConvertFrom-Metadata, ConvertTo-Metadata...}
Manifest   7.0.1      Json.Net
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty...}
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature...}
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest   3.0.0.0    Microsoft.WSMan.Management          {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, Enable-WSManCredSSP...}
Binary     1.0.0.1    PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider...}
Script     0.2.0      PoshBot                             {Get-PoshBot, Get-PoshBotConfiguration, New-PoshBotCardResponse, New-PoshBotConfiguration...}
Script     0.0        PoshBotAttribute
Script     1.0.0.1    PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability...}
Script     0.0.17     PSSlack                             {Find-SlackMessage, Get-PSSlackConfig, Get-SlackChannel, Get-SlackGroup...}

PS C:\> Get-ComputerInfo
WindowsBuildLabEx                                       : 14393.0.amd64fre.rs1_release.160715-1616
WindowsCurrentVersion                                   : 6.3
WindowsEditionId                                        : ServerDatacenterNano
WindowsInstallationType                                 : Nano Server
WindowsInstallDateFromRegistry                          : 4/14/2017 10:38:01 PM
WindowsProductId                                        :
WindowsProductName                                      : Windows Server 2016 Datacenter
[output omitted]

Psake CreateMarkdownHelp Fails Because the Module Isn't Loaded

When running psake as administrator to create markdown help files, the build script errors out because it never imports the PoshBot module.

Expected Behavior

When running the CreateMarkdownHelp task via the build script, it should automatically import the version of PoshBot available in the project root and export the function comment-based help.

Current Behavior

The build script errors out.

Possible Solution

Ensure that the module is properly loaded in a prior step or load and unload in this task itself.

Steps to Reproduce (for bugs)

  1. In a PowerShell prompt with Administrator rights, clone the project and CD to root
  2. .\build.ps1 -Task CreateMarkdownHelp

Screenshot

image

Context

Users should be able to run the build tasks without errors, even if only performing one task.

Your Environment

  • Module version used: 0.1.0
  • Operating System and PowerShell version: Windows 10.0.14393, PowerShell 5.1.14393.953
Module Version
BuildHelpers 0.0.29
Psake 4.6.0
PlatyPS 0.7.6
Pester 4.0.3
PSScriptAnalyzer 1.11.0

Error adding reaction to message when creating a function that fires on an event

Expected Behavior

Should not error out.

Current Behavior

`
{"DataTime":"2017-09-09
18:13:57Z","Class":"SlackBackend","Method":"AddReaction","Severity":"Error","LogLevel":"Info","Message":"Error adding
reaction to message","Data":{"ok":false,"error":"no_item_specified"}}
At line:6 char:9

  •     Start-PoshBot -Configuration $pbc -Verbose -ErrorVariable err
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException
      `

Steps to Reproduce (for bugs)

  1. Create a function that should fire upon an event being triggered. Example:
    `
    function WelcomeUserToRoom {
    [PoshBot.BotCommand(
    Command = $false,
    TriggerType = 'event',
    MessageType = 'PinAdded'
    )]
    [cmdletbinding()]
    param(
    [parameter(ValueFromRemainingArguments)]
    $Dummy
    )

    Write-Output 'YO YO YO'
    }
    `

  2. Trigger the function with the event (in the above case, pin a post).

  3. The error will be triggered

Context

Event-based functions does not appear to function.

Your Environment

Server 2012 R2, WMF 5.1

Cmdlet Import-PowershellDataFile not found and other issues on PowerShell version 5.0.10240.1746

When attempting to run PoshBot on a Windows machine with PowerShell version 5.0.10240.1746, it fails to run, saying that it cannot find the cmdlet Import-PowerShellDataFile. After including a function that provides similar functionality as Import-PowerShellDataFile (mapping a psd1 file to a hashtable), I get a different error after the bot receives a message.

Expected Behavior

The bot starts after running $bot.Start().

Current Behavior

When running the bot, it fails with the following error:

Import-PowerShellDataFile : The term 'Import-PowerShellDataFile' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At C:\Program Files\WindowsPowerShell\Modules\PoshBot\0.2.0\PoshBot.psm1:3362 char:25
+                 $hash = Import-PowerShellDataFile -Path $item
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Import-PowerShellDataFile:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Get-Member : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is
not null or empty, and then try the command again.
At C:\Program Files\WindowsPowerShell\Modules\PoshBot\0.2.0\PoshBot.psm1:3365 char:73
+ ...             if ($config | Get-Member -MemberType Property -Name $_) {
+                                                                     ~~
    + CategoryInfo          : InvalidData: (:) [Get-Member], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.GetMemberCommand

Configuration is missing [Token] parameter
At C:\Program Files\WindowsPowerShell\Modules\PoshBot\0.2.0\PoshBot.psm1:4894 char:17
+                 throw 'Configuration is missing [Token] parameter'
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Configuration i...oken] parameter:String) [], RuntimeException
    + FullyQualifiedErrorId : Configuration is missing [Token] parameter

This shows that the module is looking for the cmdlet, which does not exist on this version of windows. I have a machine running the latest update and PowerShell 5.1.14393.953 that has this cmdlet, and runs the same code with no issues.

Possible Solution

Upon discussing this with the developer, I edited the PoshBot.psm1 file and added the following "replacement" for the related cmdlet:

function Import-PowerShellDataFile {
    [CmdletBinding()]
    Param (
        [Parameter(Mandatory = $true)]
        [Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformation()]
        [hashtable] $Path
    )
    return $Path
}

This essentially does the same thing, it converts the $Path provided to a hashtable. After including this, the bot does successfully load and begin listening for Slack messages, however when it receives one, it displays the following error:

Exception calling "HandleMessage" with "1" argument(s): "The given key was not present in the dictionary."
At line:1 char:1
+ & 'C:\Users\aemiller\Scripts\Bot\Bot.ps1'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException

Steps to Reproduce (for bugs)

  1. Create a simple PoshBot on the PowerShell version listed
  2. Run it

Context

As it stands, I cannot use PoshBot with our current Windows image.

Your Environment

  • Module version used: 0.2.0 (installed from PSGallery)
  • Operating System and PowerShell version: Windows 10 Enterprise (Version 10.0.10240)
  • PowerShell Version: 5.0.10240.1746

Add example for Event Trigger

It would be nice to have an Event Trigger example in the documentation (Triggers.md) so newcomers like myself can understand how that works.

Standard Way to Create Plugins and Advertise on the Gallery

It would be useful to have a standard way to search the gallery for plugins written with PoshBot in mind and which leverage the roles/permissions/other models used by it.

Expected Behavior

As a naive user, I should be able to search the PSGallery for PoshBot-related modules. Even better would be a way to use PoshBot to search the gallery for plugins.

Current Behavior

I either have to know a project supports PoshBot or take an existing module and modify it for PoshBot (if I want to take advantage of permissions/etc). It is very useful to be able to download, install, and import modules from the gallery to the bot!

Possible Solution

Perhaps standardize plugins as starting with PoshBot. or PoshBot-, similar to how Mkdocs handles themes on PyPi.

We'd have to rewrite the plugin name parser to strip the prefix so the names aren't so long and silly, and we would still want to be able to use normal modules like we can now.

In the meantime, maybe having a document page which lists PoshBot-compatible modules?

Context

While PoshBot has a small user base now, it'd be nice to be able to know what modules are available which were built with PoshBot in mind and where we can take advantage of default roles/etc.

Your Environment

  • Module version used: 1.0
  • Operating System: Windows 10.0.14393
  • PowerShell Version: 5.1.14393.693

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

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.

Consider enabling comma separated parameter values

It might be worth extending the input parser to allow comma separated array input.

Many of the commands I'm writing follow a pattern of picking a set of common default properties to return, while allowing the user to specify an array of properties (passed to select-object, thus allowing wildcards and other fun)

As is, I'm using string input, no spaces, comma separated, and splitting on comma - not pretty! I see some examples using the remaining arguments for a particular parameter - that's another alternative, but a bit less natural than commas, at least for PowerShell folks (and if folks are using positional params in Slack, remaining args option might be a bit confusing)

Schedule a command to run?

It doesn't look like it's possible currently but it would be awesome to have the ability to schedule a command to run at 1 time in the future or at a repeating time in the future. Is this on the roadmap?

Slack API has a Rate Limit

It might be helpful to handle rate limits:

  • Identify spots where rate limits would be more likely to hit, if possible, make these optional, potentially use caching, and filtering to the right

    • Example: Get-Group resolves all users in every group. This could
      • (1) be avoided by adding a -ResolveUsers or some such parameter, and only resolving names in those cases, and
      • (2) be reduced to an extent by caching (e.g. in a hashtable) lookups during a run (vs. look up single ID multiple times if in multiple groups), and
      • (3) possibly be completely avoided by issuing a single 'get all users' call to pre-create the cache in (2)
  • Identify rate limit details. If possible, design generic error handling to identify when rate limit is hit, retrying after a backoff if needed

Expected Behavior

Get-Group

Groups show up...

Current Behavior

Get-Group

The remote server returned an error: (429) Too Many Requests.

Possible Solution

  • Add -ResolveUsers switch.
  • If -ResolveUsers is not specified, do not resolve users (here and here)
  • If -ResolveUsers is specified, resolve users with a delay between calls. Need to find out what the limit is, even 1 second triggered this for me, which seems absurd?

Steps to Reproduce (for bugs)

  • Add a bunch of users to groups. Or one user to many groups.
  • Run Get-Group

You can do this from Slack or just set up your $bot and run the code (a few debug bits I added included from when I was curious):

 $groups = foreach ($key in ($Bot.RoleManager.Groups.Keys | Sort-Object)) {
            Write-Verbose -Verbose -Message "Resolving [$Key] with [$($Bot.RoleManager.Groups[$key].Users.Keys.count) users] "
            [pscustomobject][ordered]@{
                Name = $key
                Description = $Bot.RoleManager.Groups[$key].Description
                Users = $Bot.RoleManager.Groups[$key].Users.Keys | foreach-object {
                    Start-Sleep -Seconds 1
                    Write-Verbose "Resolving [$_]" -Verbose
                    $Bot.RoleManager.ResolveUserToId($_)
                }
                Roles = $Bot.RoleManager.Groups[$key].Roles.Keys
            }
        }

Cheers!

Consider a mechanism for running commands as a different user

Consider a mechanism for running commands as a different user

It may be helpful to include a mechansim to simplify running as a different user.

Currently, if you need to do something with privilege XYZ, there are a few common methods:

  • Run PoshBot as account with privilege XYZ. High risk, particularly if you start doing more and more to poshbot!
  • Add per-poshbot-command handling for running as other accounts. Results in less portable commands, and ugly workarounds

Potential alternative:

Provide some convention or handling for credentials, including an option to use them when starting a job.

Hypothetical, poorly-thought-out example:

Ahead of time, as the account running PoshBot:

# Various implementation details to consider. if ^\w$, assume relative path to configuration folder? etc.
New-PoshBotConfiguration ... -Credential @{
    AD = '\\Path\To\Serialized\ADCredential'
    RT = '\\Path\To\Serialized\RTCredential'
}

Plugins and/or individual commands could be decorated to specify a credential to run with:

[PoshBot.BotCommand(
    CommandName = 'disableuser',
    Permissions = 'write',
    Credential = 'AD'
)]

The last part is tricky. Depending on how PoshBot executes commands (iirc the plan was to use jobs for now?), PoshBot could check the command or plugin config, and if a credential is specified, read the poshbot configuration, deserialize the credential, and use it to launch a job.

Whew!

Does something like this make sense? I don't see it needed in the short term, I'm currently just relying on deserializing credentials with the poshbot plugin / commands themselves, biggest concern is that this makes it a bit tough to share them, and that not all commands offer an easy way to specify credentials (in which case I would need to spawn a job, use a JEA endpoint, or some other workaround)

Cheers!

Consider persisting command history

It appears command history rolls over. It might be helpful to enable this, and perhaps default to this behavior.

Even if this data can be parsed out of the PoshBot logs, might be cleaner, easier to read, and helpful to folks using chat

Just getting the idea out there - happy to help, but haven't put much thought into design

Cheers!

Inconsistent parameter names for builtin commands

Expected Behavior

Parameter names are consistent

Current Behavior

Parameter names in the builtin commands are not consistent with each other.
For instance, Install-Plugin uses -Plugin to reference the plugin to install and Get-Role using -Role to reference the role to get. In both cases they should use -Name which is the PowerShell convention.

Possible Solution

Rename all parameters in the builtin commands to use a common naming convention.

Context

A common naming convention will help with usability as most PowerShell users are familiar with the naming convention for parameters.

Psake Requires Admin Rights

When trying to run Psake build locally, it errors out during the init task due to not having admin rights. It may also error out when resolving modules in the build.ps1 if the specified modules are not the latest available on the gallery.

Expected Behavior

Psake tasks should be able to run with normal user privileges and gracefully alert / give option to install if module versions are outdated instead of just updating them globally.

Current Behavior

Psake will attempt to upgrade/install modules globally and will fail if not running with administrator privileges.

Possible Solution

If we intend to keep the global-update behavior, the scripts should be updated to include a #requires statement for running as administrator. Otherwise, it's probably preferable to update the CI to offer the option to upgrade globally, install locally, or continue with older versions of the modules.

Steps to Reproduce (for bugs)

  1. Clone this repository.
  2. CD into the project root.
  3. .\build.ps1 -Task Init -Verbose

Screenshot

image

Context

Most users, most of the time, will be running the module build process from ISE/VSCode terminal or normal powershell console, and mostly not as administrator. This means they're likely to fail to build locally for reasons that aren't immediately clear; it also means that all build attempts for the project must be executed as administrator which seems unusual.

It also means that the build process is updating the global state of the node the build is running on - not so bad if it's a disposable runner, less fun for a personal workstation, especially if the user did not parse the build script first.

Your Environment

  • Module version used: 0.1.0
  • Operating System and PowerShell version: Windows 10.0.14393, PowerShell 5.1.14393.953

Zero's are truncated if they are the first character of a command

Expected Behavior

When sending a command where the first character of a parameter is "0" i would it expect it to be treated like any other command.

Current Behavior

Currently, if a Zero is passed in as the first character of a command, the zero is truncated.

Possible Solution

N/A
Work around is to use quotes, which is fine. However, trying to make this as easy as possible not having to include quotes would be ideal.

Steps to Reproduce (for bugs)

  1. Create a command to echo the responses.
function Echo
{
    param(
        $echo
    )
    
    Write-output $echo
}

2.Test a test !echo 01821
3.Results are just 1821

Context

i have a command that goes to get config files of products we have. By some devices start with a zero there for it errors out when getting those devices.

Also have a weather and forecast plugin where the truncated zerp would results in cities in other parts of the world.

Your Environment

Poshbot 7.1 -latest
Windows server 2016
Powershell 5.1

Consider documenting how to use NSSM to run PoshBot as a service

Getting up and running with PoshBot interactively is quite straightforward, and covered by existing docs. Some folks may find it helpful to have a short doc explaining how you could use a tool like nssm to service-ize PoshBot.

Side note: Docker is a helpful alternative, but not everyone will have that option

Again, happy to take a stab at this if you think it would be worthwhile!

Potential feature: Stateful data

Not sure if this makes sense…. but have you considered something like Get-PoshBotStatefulData and Set-PoshBotStatefulData?

This would allow workflows like… prompting for more input, prompting for confirmation, and any other stateful needs, without junking up the user’s environment. I think.

You might include a Scope parameter, or some other privacy filter - some authors may write data that only their plugin should have access to. In other cases, you might want global-to-poshbot-instance data that plugins could share to improve integration.

You might serialize to disk on Set, to ensure PoshBot could pick up state if a bot is restarted (complication: multiple instances? could work around this, but might get funky). While this might help the user, you might also include a DoNotSerialize parameter if an author is recording sensitive data (for better or worse....)

Cheers!

Save Password or Credential

Will be using BetterCredential to store creds. I'm using a CI pipeline to stand up PoshBot and I am able to store creds through Gitlab. I just need to be able to store them for remote execution for general Noc and Ops tasks.

Expected Behavior

Be able to store credential in some fashion.

Current Behavior

N/A

Possible Solution

Create a Credential module or Vault plugin or Import or partner with another module or recommendation.

Context

Trying to create a ops, noc, and dev bot to deploy through choco, to run puppet, and to reboot servers. Need to be able to store creds for multiple domains for basic functions.

PluginConfiguration and PoshBot.FromConfig

Expected Behavior

Per help New-PoshBotConfiguration -Full, this is the example found on the -PluginConfiguration parameter:

@{
    Demo = @{
        MyParam = 'bar'
    }
}

[...snip...]

function Get-Foo {
    [cmdletbinding()]
    param(
        [PoshBot.FromConfig()]
        [parameter(mandatory)]
        [string]$MyParam
    )
        
    Write-Output $MyParam
}

I expect $MyParam to default to 'bar'.

Current Behavior

Importing my custom plugin throws the following error:

❗️ Cannot find an overload for ".ctor" and the argument count: "0".

Debugging the code, I find this is actually happening here:

$cmdHelp = Get-Help -Name "$ModuleName\$($command.Name)" -ErrorAction SilentlyContinue

The Get-Help fails on my Get-Foo equivalent command while trying to import my custom plugin. After adding help, I found it's actually just choking on the [PoshBot.FromConfig()] line. I can remove that and it returns help as expected.

I believe this also happens on the included Demo plugin packaged with PoshBot.

Steps to Reproduce (for bugs)

Does !ip Demo work for anyone else right now?

Context

During new plugin development, I'm hoping to store some more...ahem...unsavory data, but I've found I'm not sure how to use the PluginConfiguration area and the PoshBot.FromConfig class in tandem.

I found the aforementioned example on the cmdlet-based help, but didn't see anything else on the ReadTheDocs site at this time.

If docs need to be updated, I'm happy to help there once this gets sorted out.

Your Environment

  • Module version used: 0.5.0
    • EDIT: And 0.6.0 / 46a6c8f in my next comment
  • Operating System and PowerShell version: Win 10 / 5.1

Implement logging in all classes

Current Behavior

Logging is not implemented fully (or at all) in every class that needs it.

Expected Behavior

All PowerShell classes that implement any kind of logic in methods should support logging for troubleshooting / auditing purposes.

Possible Solution

Derive the classes that need logging from a base class that implements it.

Context

Classes like CommandExecutor implement a ton of logic that may fail and need troubleshooting or need to be saved to a persistent medium for auditing purposes. Right now, logging is hit or miss.

Remove the "environment variable SLACK_TOKEN" mentions

It seems $env:SLACK_TOKEN is not needed.

Expected Behavior

None

Current Behavior

$env:SLACK_TOKEN is mentioned in the 'Quickstart' section of README.MD and in the comments of 'test.ps1'

Possible Solution

*Remove the 'Quickstart' ref
*delete 'test.ps1'
*if any, move missing relevant comments to 'Quickstart' and or help/docs

Funkiness with Regex command

Expected Behavior

When using a command that is based off Regex I would expect that only the command being executed at the time would be affected.

Current Behavior

I have a command based on Regex that listens for URL's. When a URL is seen in the chat the bot does something with it (shrinks URL's). However, if using another command after that the bot tries to shrink URL's still..

EXAMPLE:
Tadcrazio [6:14 PM]
www.google.com

PoshBot [6:14 PM]
https://goo.gl/fbsS ------This is Expected. 👍

Tadcrazio [6:14 PM]
!insult @tadcrazio

PoshBot [6:14 PM]
https://goo.gl/f54Uhi ----- Not Expected 👎

Tadcrazio [6:15 PM]
!remove-plugin URL ----- In order to correct it, removed the Plugin with the regex.

PoshBot [6:15 PM]
Plugin Removed

Tadcrazio [6:15 PM]
!insult @tadcrazio

Homer SimpsonAPP [6:15 PM]
When you were born, did they let your Mother out of her cell?

Possible Solution

Leave it up to you, Unless somehow my Regex pattern is affecting it.

Steps to Reproduce (for bugs)

  1. Create and Install Poshbot plugin to shorten URLs. Code sample: https://gist.github.com/tadcrazio/392a4fb45d11fc1ec7bbbfe5c302ba55
  2. Send a pattern that will get picked up by Poshbot. E.G www.google.com
    3.Results resturned. 👍
    4.Send another command @Someone
  3. Unexpected Results

Context

Trying to accomplish the bot automatically picking up long URL's in Slack and shortening them. It can clean up the chat a bit and allow insights into where and when the URL's are being viewed with Google Analytics.

Your Environment

Latest 7.1 from github
Server 2016
Powershell 5.1

CHANGELOG

This project has a changelog but it is empty.

Expected Behavior

Users and developers should be able to review a changelog for this project which adheres to the keepachangelog format and thus meets the following criteria:

  • It’s made for humans, not machines, so legibility is crucial.
  • Easy to link to any section (hence Markdown over plain text).
  • One sub-section per version.
  • List releases in reverse-chronological order (newest on top).
  • Write all dates in YYYY-MM-DD format. (Example: 2012-06-02 for June 2nd, 2012.) It’s international, sensible, and language-independent.
  • Explicitly mention whether the project follows [Semantic Versioning][https://semver.org].
  • Each version should:
    • List its release date in the above format.
    • Group changes to describe their impact on the project, as follows:
      • Added for new features.
      • Changed for changes in existing functionality.
      • Deprecated for once-stable features removed in upcoming releases.
      • Removed for deprecated features removed in this release.
      • Fixed for any bug fixes.
      • Security to invite users to upgrade in case of vulnerabilities.

Current Behavior

The project has an empty changelog file.

Possible Solution

Use the keepachangelog format and ensure that it is updated for each new version/release.

Context

Keeping a standardized changelog makes it easy for people to see and understand what has happened version to version and when those versions were released.

Error when installing modules from PSGallery when the module has a dependency on PoshBot

Expected Behavior

Modules are installed without error.

Current Behavior

When installing a module from the PSGallery that itself has a dependency on PoshBot. PowerShell will throw the error below:

The following commands are already available on this system:'Export-Metadata'. This module 'Configuration' may override the existing commands. If you still want to install this module 'Configuration', use -AllowClobber parameter.

This is probably because PoshBot has a dependency on Configuration so it is already loaded in the running instance of PoshBot. When PoshBot attempts to install a module that depends on PoshBot, OneGet attempts to install the dependency Configuration and throws this error. Since Configuration is already installed I'm not quite sure why it's trying to install it again.

Possible Solution

Add -AllowClobber switch to Install-Module cmdlet in the builtin command Install-Plugin.

Steps to Reproduce (for bugs)

Install the PoshBot.Wolfram module from the PSGallery with

!install-plugin --name poshbot.wolfram

Context

This is a pretty critical bug as any module on PSGallery that depends on PoshBot can't be installed.

Your Environment

  • Module version used: 0.1.0
  • Operating System and PowerShell version: Win10 build 15063, PowerShell v5.1.15063.0

Get-Group output may not include all data

Get-Group output can miss data if an array is long enough.

Expected Behavior

Get-Group

Name        : sysadmin
Description : Read and write access
Users       : {a, b, c, d, e, f, g}
Roles       : {1, 2, 3, 4, 5, 6}

Current Behavior

Get-Group

Name        : sysadmin
Description : Read and write access
Users       : {a, b, c, d...}
Roles       : {1, 2, 3, 4...}

Possible Solution

  • Set $FormatEnumerationLimit = -1 in the PoshBot environment. Generally, elllipsis are bad, if you have no recourse to further explore objects (i.e. with raw PowerShell), it seems like forcing this in the environment (perhaps with an option to override via config) would be acceptable
  • Get fancy and customize the output - this seems less 'built in' and could be delicate

Happy to help if you have any preferences in direction : )

Cheers!

Parsing URL's that contain Parentheses does not seem to parse properly.

Expected Behavior

I would expect it to parse all commands regardless of the characters in the command.

Current Behavior

When passing in a command, in my case a URL that i want to do something with the bot tends fail if the URL contains parentheses.

Possible Solution

Sadly, i don't have any solutions. I believe the bug may lay in the commandparser.ps1.

Steps to Reproduce (for bugs)

  1. Create a basic plugin that echo's the command that was inputted.
  2. use the command in Poshbot in my case it was a url. "http://www.google.com:this:wouldbemoreofaurl()"
  3. See that poshbot will recognize the message but not echo back the results.

Super simple function i tested with.

function S
{
    [cmdletbinding()]
    param(
        $text
    )
 
    Write-output $text
}

Context

I've been trying to find a way for poshbot to automatically shrink URL's. I've tried multiple ways of doing this but kept running into issues and kept chalking it up to the way i was writing my plugins. After finally have a way that works great I ran into more issues and found out it's not with my plugins but with the bot itself.

Your Environment

Using Poshbot 0.7.0 from github
Server 2016
Powershell 5.1

Feature Request - Ability to send message to user that may not have initiated the conversation

Poshbot currently provides the ability to respond to a user based on something - either in the same channel or via DM, but that workflow appears to require that the user initiate that communication. It would be slick to provide the ability to @ or DM a user without the user initiating that conversation.

Expected Behavior

Allow poshbot to message a user without the user initiating the conversation.

Current Behavior

Does not appear to allow this functionality.

Context

Allow the user to tell poshbot to look for a particular thing to happen (a particular user comes online, a system is available, etc), and DM the user when that condition is met.

Your Environment

Server 2012 R2, WMF5.1.

Documentation Issues in Triggers.md

Expected Behavior

Correct documentation

Current Behavior

Misspelled word in Event Example 2 - "The next work can be anything" - work should be word.

Missing Command = $false in 2nd Event Example

Possible Solution

Will update documentation and submit pull request.

Consider documenting build process for contributors

It might be helpful to have a simple how to make changes, test/build locally doc

Not super complex, but this delayed me for a bit - every time I had a few spare minutes to work 'oh! gotta figure out how to run the build to actually produce a module we can import.' This might slow things down for contributors or scare off folks who have something to contribute but aren't quite familiar with the build tools.

Happy to take a stab at this if you think it makes sense.

Side note: I'm completely guilty of this myself : )

New Feature: File Uploads

PoshBot currently supports custom text responses via New-PoshBotTextResponse and New-PoshBotCardResponse. These send custom object types back in the output stream so PoshBot can detect them and handle the custom formatting of the response. It would be nice if PoshBot was able to be told to upload a file without the plugin author needing to handle the particulars for the current backend.

Proposed Command

New-PoshBotFileUpload would be given a path to a file and send that information back to PoshBot. When PoshBot processes the response from the command, it would detect this custom response object, read in the file, and send to the backend for upload.

Example Usage

function Do-Stuff {
    [cmdletbinding()]
    param()

    $myObj = [pscustomobject]@{
        value1 = 'foo'
        value2 = 'bar'
    }

    $csv = Join-Path -Path $env:TEMP -ChildPath "$((New-Guid).ToString()).csv"
    $myObj | Export-Csv -Path $csv -NoTypeInformation
    
    New-PoshBotFileUpload -Path $csv
}

Constrained runtime for commands

I'm quite comfort with the current implementation.

Down the road, if this grows, it might be fun and potentially helpful for folks with a different risk appetite to do something like... dynamically constrain each runspace that a command runs in. Available functions, variables, etc. For the paranoid.

Might not even be worth the effort, just brainstorming!

Zero's being truncated if it is the first character in a command

Expected Behavior

When sending a command where the first character of a parameter is "0" i would it expect it to be treated like any other command.

Current Behavior

Currently, if a Zero is passed in as the first character of a command, the zero is truncated.

Possible Solution

N/A
Work around is to use quotes, which is fine. However, trying to make this as easy as possible not having to include quotes would be ideal.

Steps to Reproduce (for bugs)

  1. Create a command to echo the responses.
function Echo
{
    param(
        $echo
    )
    
    Write-output $echo
}

2.Test a test !echo 01821
3.Results are just 1821

Context

i have a command that goes to get config files of products we have. By some devices start with a zero there for it errors out when getting those devices.

Also have a weather and forecast plugin where the truncated zerp would results in cities in other parts of the world.

Your Environment

Poshbot 7.1 -latest
Windows server 2016
Powershell 5.1

Shipit?

I have a question for those of you you have been testing this module. Have you run into any glaring bugs that would cause you to hesitate publishing on the PowerShell Gallery?

Other than some missing documentation (which will be corrected) I feel this is ready to ship as v1.0 but would be curious what others think.

Warning logged when Event is triggered

Expected Behavior

Warning should probably not be triggered.

Current Behavior

18:07:13Z","Class":"PluginManager","Method":"MatchCommand","Severity":"Warning","LogLevel":"Info","Message":"Unable to match parsed command [:] to a plugin command","Data":{}}

Steps to Reproduce (for bugs)

  1. Launch poshbot with default configuration
  2. Trigger an event (adding a reaction to a message, etc.
  3. The message is logged

Context

Annoyance only.

Your Environment

Server 2012 R2, PS version 5.1

Support message reactions to indicate commands are running, succeeded, or failed

Expected Behavior

Visual indication that the bot is processing a command given to it. Some commands may be long running and it would be good UX to notify the user that the bot received the message and is processing it.

It would also be handy to mark the message as completed or failed as bot commands/responses in a busy channel may be interwoven with normal user messages and it may not be apparent if a command succeeded or not.

Current Behavior

There is currently no indication that the bot is running the command the user entered.

Possible Solution

  1. Add a processing reaction as soon as the bot begins executing a command. When the command completes (successfully or with errors), the processing reaction is removed.
    processing

  2. Add a success reaction when a command completed successfully.
    success

  3. Add a failure reaction when the command returns with a failure.
    failure

Exception installing PowerShell module when the module includes cmdlets

Expected Behavior

PoshBot should be able to import and execute both functions and cmdlets from PowerShell modules.

Current Behavior

When importing a plugin (PowerShell module) into PoshBot, exeptions are thrown when importing cmdlets. Functions work fine.

Cannot convert argument "Command", with value: "Resolve-DnsName", for "GetCommandMetadata" to type "System.Management.Automation.FunctionInfo": "Cannot convert the "Resolve-DnsName" value of type "System.Management.Automation.CmdletInfo" to type "System.Management.Automation.FunctionInfo"."

Possible Solution

This is because internally, PoshBot retrieves all the commands from the installed module via Microsoft.PowerShell.Core\Get-Command -Module $ModuleName -CommandType @('Cmdlet', 'Function', 'Workflow') but stores the commands in a FunctionInfo property of the created PoshBot Command instance. FunctionInfo is of type [System.Management.Automation.FunctionInfo] and exceptions will be thrown if commands of type [System.Management.Automation.CmdletInfo] are stored there.

To fix this, the PoshBot Command class should be modified to accept commands of type FunctionInfo and CmdletInfo. The PluginManager and CommandExecutor classes will also need to be modified to handle the logic for dealing with commands of either type appropriately.

Steps to Reproduce (for bugs)

Run the following command in PoshBot to install the DnsClient module. This module includes both functions and cmdlets.

!install-plugin dnsclient

Context

PoshBot should be able to install and execute either functions or cmdlets.

Your Environment

  • Module version used: 0.7.0
  • Operating System and PowerShell version: Windows 10 16257.1, PowerShell 5.1.16257.1

Consider mechanism for a watchdog of sorts

It might be worth adding a watchdog process of sorts. For example:

  • Define a watch interval
  • In loop that reads from API, include logic to
    • check if watch interval exceeded...
    • send message to bot via private message
    • validate that we receive message within acceptable period of time
    • if we don't receive message... do something (log error and reconnect? disconnect/throw?)

Not sure if this is feasible (i.e. do all back ends have concept of a private message to yourself?)

Every so often I find the bot disconnects, with the service still running, and nothing apparent in logs - a watcher might help resolve this when it happens

Cheers!

Feature Request: Startup Script for configurations.

Startup Script: Trying to push this through a CI and would like to set psrepo in some sort of startup script in my New-PoshBotScheduledTask. Also, I had to add are reboot to the CI task to make poshbot come up at the end. It'd be nice if I would be able to start tasks instead of reboot. Also more through documentation of the plugin directories, the *.psd1 files I put there don't seem to be loaded when I specify them in ModuleManifestsToLoad.

Expected Behavior

new Parameter for StartupScript = "$botdir.poshbot\startup.ps1"

Current Behavior

null

Moving project to PoshBotIO organization

I created a new GitHub organization PoshBotIO to hold all the related PoshBot projects. I intend to move this project into that organization in the next few days. While this shouldn't cause any problems, I figured I'd raise this issue to notify everyone.

https://help.github.com/articles/about-repository-transfers/

What you need to do

After I transfer the project, your git remote links should still work and redirect to the new location but to avoid any confusion, it is strongly recommended to run:

git remote set-url origin <new_url>

I'll let this issue simmer for a few days before I move the project. Once I do, I'll respond to this issue with the new URL.

New function to create a scheduled task to run PoshBot in the background

Expected Behavior

PoshBot should be able to run in the background

Current Behavior

No function exists. The user is left to their own devices to get PoshBot running in the background.

Possible Solution

Add new function to create a scheduled task that runs a small entry point script to load the PoshBot configuration file and start PoshBot.

Context

Allow PoshBot to be running in the background and ensure it starts after a restart.

Your Environment

  • Module version used: 1.0
  • Operating System and PowerShell version: Windows 10 build 15061.0, PowerShell 5.1.15061.0

Get-CommandHelp is difficult for overlapping names

Let's pretend we have a plugin with 3 commands:

  • Group
  • GroupMember
  • Groups

It is difficult to get help for Group

Expected Behavior

!help Group

Detailed help for Group appears

Current Behavior

!help Group

Everything with group in it comes back. Even if I fully specify the fully qualified names

!help Group -detailed

Everything with group in it comes back. Even if I fully specify the fully qualified names

Possible Solution

Code here

I do like the fuzzy-ish search to simplify usage. That said, from my perspective, if a commandname has an exact match, only that item should be returned. Perhaps move to:

  • if exact match on command or alias, detail on that match
  • elseif fuzzy matches (existing logic)
  • else (existing logic)

Completely open to alternatives though (e.g. another parameter that doesn't do fuzzy matching)

Context

Getting help for commands with generic names that are found elsewhere is difficult if not impossible (I might be overlooking something).

We currently list out example uses on a doc page, but down the line I would expect bot !help usage to become the preferred option.

Cheers!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.