Skip to content

Commit

Permalink
Merge pull request #80 from DWOF/DAH_Contribution
Browse files Browse the repository at this point in the history
Changed to new api method. Fixes #79
  • Loading branch information
RamblingCookieMonster authored May 22, 2019
2 parents dcabbee + d827485 commit 5f85d19
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions PSSlack/Public/Get-SlackChannel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
.PARAMETER Name
One or more channel names to return. Defaults to all. Accepts wildcards.
.PARAMETER Types
Mix and match channel types by providing array of any combination of public_channel, private_channel, mpim, im
.PARAMETER ExcludeArchived
Whether to exclude archived channels. Default is to include all.
Expand All @@ -28,25 +31,37 @@
param (
$Token = $Script:PSSlack.Token,
[string[]]$Name,
[ValidateSet('public_channel', 'private_channel', 'mpim', 'im')]
[string[]]$Types,
[switch]$ExcludeArchived,
[switch]$Raw
)
end
{
Write-Verbose "$($PSBoundParameters | Remove-SensitiveData | Out-String)"
$body = @{}
if ($ExcludeArchived)
{
$body.Add("exclude_archived",1)
}
else
{
$body.Add("exclude_archived",0)
}

if($ExcludeArchived)
if ($Types)
{
$body = @{ exclude_archived = 1 }
$body.add("types",$($Types -join ","))
}
else
{
$body = @{ exclude_archived = 0 }
$body.add("types","public_channel,private_channel")
}

$params = @{
Body = $body
Token = $Token
Method = 'channels.list'
Method = 'conversations.list'
}
$RawChannels = Send-SlackApi @params

Expand Down Expand Up @@ -99,4 +114,4 @@
Parse-SlackChannel -InputObject $Channels
}
}
}
}

0 comments on commit 5f85d19

Please sign in to comment.