poshbotio / PoshBot

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

New Feature: File Uploads #37

Closed devblackops closed 7 years ago

devblackops commented 7 years ago

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
}