PSSlack
PSSlack copied to clipboard
support tor thread_ts in send-slackfile and send-slackmessage
send-slackfile and send-slackmessage should support threads
send-slackfile should be modified as follows:
...
[parameter(ParameterSetName = 'Content')]
[string]$FileType,
[string[]]$Channel,
[string]$thread_ts,
[string]$FileName,
[String]$Title,
[String]$Comment,
...
process
{
if ($Content) {
$body = @{}
switch ($psboundparameters.keys) {
'Content' {$body.content = $content}
'Channel' {$body.channels = $Channel -join ", " }
'thread_ts' {$body.thread_ts = $thread_ts}
'FileName' {$body.filename = $FileName}
'Title' {$body.Title = $Title}
'Comment' {$body.initial_comment = $Comment}
'FileType' {$body.filetype = $FileType}
}
...
switch ($psboundparameters.keys) {
'Channel' {$bodyLines +=
("--$boundary$LF" +
"Content-Disposition: form-data; name="channels
"$LF" +
"Content-Type: multipart/form-data$LF$LF" +
($Channel -join ", ") + $LF)}
'thread_ts' {$bodyLines +=
("--$boundary$LF" +
"Content-Disposition: form-data; name=`"thread_ts`"$LF" +
"Content-Type: multipart/form-data$LF$LF" +
"$thread_ts$LF")}
'FileName' {$bodyLines +=
("--$boundary$LF" +
"Content-Disposition: form-data; name=`"filename`"$LF" +
"Content-Type: multipart/form-data$LF$LF" +
"$FileName$LF")}
send-slackmessage ... $Username,
[parameter(ParameterSetName = 'Param',
ValueFromPipelineByPropertyName = $True)]
$thread_ts,
[parameter(ParameterSetName = 'Param',
ValueFromPipelineByPropertyName = $True)]
$IconUrl,
[parameter(ParameterSetName = 'Param',
ValueFromPipelineByPropertyName = $True)]
$IconEmoji,
... if($PSCmdlet.ParameterSetName -eq 'Param') { $body = @{ }
switch ($psboundparameters.keys)
{
'channel' {$body.channel = $channel }
'text' {$body.text = $text}
'username' {$body.username = $username}
'thread_ts' {$body.thread_ts = $thread_ts}
'asuser' {$body.as_user = $AsUser}
'iconurl' {$body.icon_url = $iconurl}
'iconemoji' {$body.icon_emoji = $iconemoji}
'linknames' {$body.link_names = 1}
'parse' {$body.parse = $Parse}
'UnfurlLinks' {$body.unfurl_links = $UnfurlLinks}
'UnfurlMedia' {$body.unfurl_media = $UnfurlMedia}
'attachments' {$body.attachments = $Attachments}
}
$Messages += $Body
....
@atartareanu I was looking for this as well. Would you be able to submit a PR request since you have the code already figured out? CC @RamblingCookieMonster
As of 2/21 it looks like the thread_ts
has been removed from channels.replies, but has been replaced in the conversations.replies with just ts
.
@rvigliotti-sf and @atartareanu this should know be in version 1.0.6 of the module.