Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multiple cardresponses in function #199

Open
joakimkarlbom opened this issue Jan 9, 2020 · 2 comments
Open

Support for multiple cardresponses in function #199

joakimkarlbom opened this issue Jan 9, 2020 · 2 comments
Assignees
Labels
enhancement pinned Prevent closing if stale

Comments

@joakimkarlbom
Copy link
Contributor

joakimkarlbom commented Jan 9, 2020

Expected Behavior

When doing multiple New-PoshBotCardResponse's within a function, the expected outcome should be that it sends the response at the time it is run in the function, and not batched when it has completed.

Current Behavior

Right now, Poshbot will batch all CardResponses until the function either completes or fails.

Possible Solution

This is probably the two places where the logic needs to be changed:
I have made some attempts by changing line 167-168 in https://github.com/poshbotio/PoshBot/blob/master/PoshBot/Classes/CommandExecutor.ps1#L162 to

Where-Object {($_.Value.Complete -eq $true) -or
                              ($_.Value.IsJob -and (($_.Value.Job.State -eq 'Completed') -or ($_.Value.Job.State -eq 'Failed')-or ($_.Value.Job.State -eq 'Running')))} |

and commenting out line 476-479 in https://github.com/poshbotio/PoshBot/blob/master/PoshBot/Classes/Bot.ps1#L460 like so:

                       } <# else {
                            $cmdExecContext.Response.Data += New-PoshBotCardResponse -Type Error -Text 'Something bad happened :(' -Title 'Command Error'
                            $cmdExecContext.Response.Data += $cmdExecContext.Result.Errors
                        } #>

Steps to Reproduce (for bugs)

(made by Brandon Olin)
function Start-LongRunningCommand {
[cmdletbinding()]
param(
[int]$Count = 5,
[int]$DelaySeconds = 2
)

(1..$Count) | % {
    New-PoshBotCardResponse -Text "$_ of $Count...waiting $DelaySeconds seconds"
    Start-Sleep -Seconds $DelaySeconds
}

}

Context

I want more verbose output on each step within more complex functions

Your Environment

  • Module version used:
  • Operating System and PowerShell version:
@devblackops
Copy link
Member

Thanks for the issue @joakimkarlbom. I'll take a look at this when I get a chance to determine if we need to modify more of the code to support this.

@devblackops devblackops self-assigned this Jan 13, 2020
@stale
Copy link

stale bot commented Mar 13, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement pinned Prevent closing if stale
Projects
None yet
Development

No branches or pull requests

2 participants