2023-03-13 22:00:26 -07:00
|
|
|
#!/usr/local/bin/pwsh
|
2023-03-11 10:43:06 -08:00
|
|
|
param (
|
|
|
|
[string] $ApiServer = "http://localhost:5011",
|
|
|
|
[string] $JsonSecrets = "./seed.secrets.json"
|
|
|
|
)
|
|
|
|
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
|
2023-03-31 22:49:39 -07:00
|
|
|
function New-RedditSource {
|
2023-03-11 10:43:06 -08:00
|
|
|
param (
|
2023-04-01 08:53:34 -07:00
|
|
|
[string] $Name
|
2023-03-11 10:43:06 -08:00
|
|
|
)
|
|
|
|
|
2023-04-01 08:53:34 -07:00
|
|
|
$param = "name=$Name"
|
2023-03-11 10:43:06 -08:00
|
|
|
$uri = "$ApiServer/api/sources/new/reddit?$param"
|
|
|
|
$res = Invoke-RestMethod -Method Post -Uri $uri
|
|
|
|
return $res
|
|
|
|
}
|
|
|
|
|
2023-03-31 22:49:39 -07:00
|
|
|
function New-RssSource {
|
2023-03-11 10:43:06 -08:00
|
|
|
param (
|
|
|
|
[string] $Name,
|
|
|
|
[string] $Url
|
|
|
|
)
|
|
|
|
$urlEncoded = [uri]::EscapeDataString($Url)
|
|
|
|
$param = "name=$Name&url=$urlEncoded"
|
|
|
|
[string] $uri = "$ApiServer/api/sources/new/rss?$param"
|
|
|
|
$res = Invoke-RestMethod -Method Post -Uri $uri
|
|
|
|
return $res
|
|
|
|
}
|
|
|
|
|
2023-03-31 22:49:39 -07:00
|
|
|
function New-YoutubeSource {
|
2023-03-11 10:43:06 -08:00
|
|
|
param (
|
2023-04-01 08:53:34 -07:00
|
|
|
[string] $Url
|
2023-03-11 10:43:06 -08:00
|
|
|
)
|
|
|
|
$urlEncoded = [uri]::EscapeDataString($Url)
|
2023-03-31 22:49:39 -07:00
|
|
|
[string] $param = "url=$urlEncoded"
|
2023-03-11 10:43:06 -08:00
|
|
|
[string] $uri = "$ApiServer/api/sources/new/youtube?$param"
|
|
|
|
$res = Invoke-RestMethod -Method Post -Uri $uri
|
|
|
|
return $res
|
|
|
|
}
|
|
|
|
|
2023-03-31 22:49:39 -07:00
|
|
|
function New-TwitchSource {
|
2023-03-11 10:43:06 -08:00
|
|
|
param (
|
|
|
|
[string] $Name
|
|
|
|
)
|
|
|
|
[string] $param = "name=$Name"
|
|
|
|
[string] $uri = "$ApiServer/api/sources/new/twitch?$param"
|
|
|
|
$res = Invoke-RestMethod -Method Post -Uri $uri
|
|
|
|
return $res
|
|
|
|
}
|
|
|
|
|
|
|
|
function New-DiscordWebhook {
|
|
|
|
param (
|
|
|
|
[string] $Server,
|
|
|
|
[string] $Channel,
|
|
|
|
[string] $Url
|
|
|
|
)
|
|
|
|
$urlEncoded = [uri]::EscapeDataString($Url)
|
|
|
|
[string] $param = "server=$Server&channel=$Channel&url=$urlEncoded"
|
|
|
|
[string] $uri = "$ApiServer/api/discord/webhooks?$param"
|
|
|
|
Write-Host $uri
|
|
|
|
$res = Invoke-RestMethod -Method Post -Uri $uri
|
|
|
|
return $res
|
|
|
|
}
|
|
|
|
|
|
|
|
function New-Subscription {
|
|
|
|
param (
|
|
|
|
[string] $SourceId,
|
|
|
|
[string] $DiscordWebhookId
|
|
|
|
)
|
|
|
|
[string] $param = "sourceId=$SourceId&discordId=$DiscordWebhookId"
|
|
|
|
[string] $uri = "$ApiServer/api/subscriptions?$param"
|
|
|
|
$res = Invoke-RestMethod -Method Post -Uri $uri
|
|
|
|
return $res
|
|
|
|
}
|
|
|
|
|
|
|
|
# Load Secrets file
|
|
|
|
$secrets = Get-Content $JsonSecrets -Raw | ConvertFrom-Json
|
|
|
|
|
2023-03-31 22:49:39 -07:00
|
|
|
$redditDadJokes = New-RedditSource -Name "dadjokes"
|
|
|
|
$redditSteamDeck = New-RedditSource -Name "steamdeck"
|
2023-03-11 10:43:06 -08:00
|
|
|
|
2023-03-31 22:49:39 -07:00
|
|
|
$rssSteamDeck = New-RssSource -Name "Steampowered - Steam Deck" -Url "https://store.steampowered.com/feeds/news/app/1675200/?cc=US&l=english&snr=1_2108_9__2107"
|
|
|
|
$rssFaysHaremporium = New-RssSource -Name "Fay's Haremporium" -Url "https://blog.nyxstudios.moe/rss/"
|
|
|
|
$rssPodcastLetsMosley = New-RssSource -Name "Let's Mosley" -Url "https://anchor.fm/s/6c7aa4c4/podcast/rss"
|
2023-04-08 10:10:08 -07:00
|
|
|
$rssOmgLinux = New-RssSource -Name "Omg! Linux" -Url "https://www.omglinux.com/feed"
|
|
|
|
$rssEngadget = New-RssSource -Name "Engadget" -Url "https://www.engadget.com/rss.xml"
|
|
|
|
$rssArsTechnica = New-RssSource -Name "Ars Technica" -Url "https://feeds.arstechnica.com/arstechnica/index"
|
2023-03-11 10:43:06 -08:00
|
|
|
|
2023-03-31 22:49:39 -07:00
|
|
|
$youtubeGameGrumps = New-YoutubeSource -Url "https://www.youtube.com/user/GameGrumps"
|
|
|
|
$youtubeCityPlannerPlays = New-YoutubeSource -Url "https://www.youtube.com/c/cityplannerplays"
|
|
|
|
$youtubeLinusTechTips = New-YoutubeSource -Url "https://www.youtube.com/@LinusTechTips"
|
2023-04-08 10:10:08 -07:00
|
|
|
$youtubeFireship = New-YoutubeSource -Url "https://www.youtube.com/@Fireship"
|
|
|
|
$youtubeClimateTown = New-YoutubeSource -Url "https://www.youtube.com/c/ClimateTown"
|
|
|
|
|
2023-03-11 10:43:06 -08:00
|
|
|
|
2023-04-01 08:53:34 -07:00
|
|
|
$twitchNintendo = New-TwitchSource -Name "Nintendo"
|
2023-03-11 10:43:06 -08:00
|
|
|
|
2023-04-08 10:10:08 -07:00
|
|
|
$miharuMonitor = New-DiscordWebhook -Server "Miharu Monitor" -Channel "dev" -Url $secrets.MiharuMonitor.dev02
|
|
|
|
$sky = New-DiscordWebhook -Server "Let's Mosley" -Channel "bot test" -url $secrets.LetsMosley.test
|
2023-03-11 10:43:06 -08:00
|
|
|
|
|
|
|
New-Subscription -SourceId $redditDadJokes.id -DiscordWebhookId $miharuMonitor.id
|
|
|
|
New-Subscription -SourceId $redditSteamDeck.id -DiscordWebhookId $miharuMonitor.id
|
|
|
|
New-Subscription -SourceId $rssSteamDeck.id -DiscordWebhookId $miharuMonitor.id
|
|
|
|
New-Subscription -SourceId $rssFaysHaremporium.id -DiscordWebhookId $miharuMonitor.id
|
|
|
|
New-Subscription -SourceId $rssPodcastLetsMosley.id -DiscordWebhookId $miharuMonitor.id
|
2023-04-08 10:10:08 -07:00
|
|
|
New-Subscription -SourceId $rssPodcastLetsMosley.id -DiscordWebhookId $sky.id
|
|
|
|
New-Subscription -SourceId $rssOmgLinux.id -DiscordWebhookId $miharuMonitor.id
|
|
|
|
New-Subscription -SourceId $rssEngadget.id -DiscordWebhookId $miharuMonitor.id
|
|
|
|
New-Subscription -SourceId $rssArsTechnica.id -DiscordWebhookId $miharuMonitor.id
|
2023-03-11 10:43:06 -08:00
|
|
|
New-Subscription -SourceId $youtubeGameGrumps.id -DiscordWebhookId $miharuMonitor.id
|
|
|
|
New-Subscription -SourceId $youtubeCityPlannerPlays.id -DiscordWebhookId $miharuMonitor.id
|
2023-03-31 22:49:39 -07:00
|
|
|
New-Subscription -SourceId $youtubeLinusTechTips.id -DiscordWebhookId $miharuMonitor.id
|
2023-04-08 10:10:08 -07:00
|
|
|
New-Subscription -SourceId $youtubeFireship.id -DiscordWebhookId $miharuMonitor.id
|
|
|
|
New-Subscription -SourceId $youtubeClimateTown.id -DiscordWebhookId $miharuMonitor.id
|
2023-03-11 10:43:06 -08:00
|
|
|
New-Subscription -SourceId $twitchNintendo.id -DiscordWebhookId $miharuMonitor.id
|