Integrations/Slack.psm1
|
# Slack Integration Module for MiMo CLI # Provides integration with Slack API function Send-SlackMessage { [CmdletBinding()] param( [Parameter(Mandatory=$true)] [string]$Token, [Parameter(Mandatory=$true)] [string]$Channel, [Parameter(Mandatory=$true)] [string]$Text ) $url = "https://slack.com/api/chat.postMessage" $body = @{ token = $Token channel = $Channel text = $Text } try { $response = Invoke-RestMethod -Uri $url -Method Post -Body $body return $response } catch { Write-Error "Failed to send Slack message: $_" return $null } } function Get-SlackChannels { [CmdletBinding()] param( [Parameter(Mandatory=$true)] [string]$Token ) $url = "https://slack.com/api/channels.list?token=$Token" try { $response = Invoke-RestMethod -Uri $url -Method Get return $response.channels } catch { Write-Error "Failed to get Slack channels: $_" return $null } } function Get-SlackUsers { [CmdletBinding()] param( [Parameter(Mandatory=$true)] [string]$Token ) $url = "https://slack.com/api/users.list?token=$Token" try { $response = Invoke-RestMethod -Uri $url -Method Get return $response.members } catch { Write-Error "Failed to get Slack users: $_" return $null } } # Export functions Export-ModuleMember -Function Send-SlackMessage, Get-SlackChannels, Get-SlackUsers |