-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSlackWeb.psm1
45 lines (37 loc) · 1.57 KB
/
SlackWeb.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#Requires -Version 3.0
$ModulePath = $PSScriptRoot
foreach ($FunctionType in @('Private', 'Public')) {
$Path = Join-Path -Path $ModulePath -ChildPath ('{0}\*.ps1' -f $FunctionType)
if (Test-Path -Path $Path) {
Get-ChildItem -Path $Path -Recurse | ForEach-Object -Process { . $_.FullName }
}
}
$ModuleConfiguration = Get-SlackWebConfiguration
$ModuleWideMessageRepliesRateLimitSeconds = $ModuleConfiguration.MessageRepliesRateLimitSeconds
$ModuleWideFormBoundaryCommonPart = $ModuleConfiguration.FormBoundaryCommonPart
$ModuleWideUA = $ModuleConfiguration.UA
$ModuleWideToken = $ModuleConfiguration.Token
$ModuleWideCookie = $ModuleConfiguration.Cookie
$WriteDownConfig = $false
if (-not $ModuleWideToken) {
Write-Warning -Message 'Your token value is not defined. Please, set it now.'
$ModuleWideToken = Read-Host -Prompt 'Your token, please'
$WriteDownConfig = $true
}
if (-not $ModuleWideCookie) {
Write-Warning -Message 'Your d-cookie value is not defined. Please, set it now.'
$ModuleWideCookie = Read-Host -Prompt 'Your d-cookie, please'
$WriteDownConfig = $true
}
if ($WriteDownConfig) {
Set-SlackWebConfiguration -InitialConfiguration
}
$FormData = [ordered]@{
include_unlisted_if_admin = $false
token = '' # This property is filled by Invoke-ApiRequest
_x_reason = 'conditional-fetching'
}
$Response = Invoke-ApiRequest -Method 'team.info' -FormData $FormData
$TeamInfo = $Response.Content | ConvertFrom-Json
$ModuleWideTeamID = $TeamInfo.team.id
$ModuleWideTeamDomain = $TeamInfo.team.domain