Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions PoshBot/Classes/Bot.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class Bot : BaseLogger {

# Disable $PSStyle output rendering so ANSI escape sequences
# don't get sent back to the chat backend
if ($global:PSStyle) {
$global:PSStyle.OutputRendering = [Management.Automation.OutputRendering]::Host
}
# if ($global:PSStyle) {
# $global:PSStyle.OutputRendering = [Management.Automation.OutputRendering]::Host
# }

# Attach the logger to the backend
$this.Backend.Logger = $this.Logger
Expand Down
2 changes: 2 additions & 0 deletions PoshBot/Classes/ConnectionConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class ConnectionConfig {

[pscredential]$Credential

[pscredential]$CredentialApp

ConnectionConfig() {}

ConnectionConfig([string]$Endpoint, [pscredential]$Credential) {
Expand Down
17 changes: 15 additions & 2 deletions PoshBot/Implementations/Slack/SlackBackend.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ class SlackBackend : Backend {
$sendTo = "@$($this.UserIdToUsername($Response.MessageFrom))"
}

$threadId = [string]::Empty
if ($customResponse.TH) {
$threadId = "@$($Response.OriginalMessage.RawMessage.ts)"
}

switch -Regex ($customResponse.PSObject.TypeNames[0]) {
'(.*?)PoshBot\.Card\.Response' {
$this.LogDebug('Custom response is [PoshBot.Card.Response]')
Expand Down Expand Up @@ -420,7 +425,11 @@ class SlackBackend : Backend {
$attParams.Text = [string]::Empty
}
$att = New-SlackMessageAttachment @attParams
$msg = $att | New-SlackMessage -Channel $sendTo -AsUser
if([string]::IsNullOrEmpty($threadId)){
$msg = $att | New-SlackMessage -Channel $sendTo -AsUser
}else{
$msg = $att | New-SlackMessage -Channel $sendTo -AsUser -Thread $threadId
}
$this.LogDebug("Sending card response back to Slack channel [$sendTo]", $att)
$msg | Send-SlackMessage -Token $this.Connection.Config.Credential.GetNetworkCredential().Password -Verbose:$false > $null
}
Expand All @@ -436,7 +445,11 @@ class SlackBackend : Backend {
$t = $chunk
}
$this.LogDebug("Sending text response back to Slack channel [$sendTo]", $t)
Send-SlackMessage -Token $this.Connection.Config.Credential.GetNetworkCredential().Password -Channel $sendTo -Text $t -Verbose:$false -AsUser > $null
if([string]::IsNullOrEmpty($threadId)){
Send-SlackMessage -Token $this.Connection.Config.Credential.GetNetworkCredential().Password -Channel $sendTo -Text $t -Verbose:$false -AsUser > $null
}else{
Send-SlackMessage -Token $this.Connection.Config.Credential.GetNetworkCredential().Password -Channel $sendTo -Text $t -Verbose:$false -AsUser -Thread $threadId > $null
}
}
break
}
Expand Down
Loading