Last active
July 14, 2018 16:51
-
-
Save nyanshiba/302e0ebaf07a8185a4e84cb76258ff9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#180711 | |
#_EDCBX_HIDE_ | |
#視聴予約なら終了 | |
if ($env:RecMode -eq 4) { exit } | |
#====================ユーザ設定==================== | |
#--------------------Twitter-------------------- | |
#ruby.exe | |
$ruby_path='C:\Ruby25-x64\bin\ruby.exe' | |
#tweet.rb | |
$tweet_rb_path='C:\DTV\EDCB\tweet.rb' | |
#SSL証明書(環境変数) | |
$env:ssl_cert_file='C:\DTV\EDCB\cacert.pem' | |
#--------------------Discord-------------------- | |
#webhook url | |
$hookUrl = 'https://discordapp.com/api/webhooks/XXXXXXXXXX' | |
#====================ハッシュタグ判別==================== | |
#環境変数ServiceNameはChSet5.txt参照 | |
#環境変数hashtagはTwitter参照 | |
#BS | |
switch ($env:ServiceName) { | |
#BS | |
"NHKBS1" {$hashtag='#nhkbs1'} | |
"NHKBSプレミアム" {$hashtag='#nhkbsp'} | |
"BS日テレ" {$hashtag='#bsntv'} | |
"BS朝日1" {$hashtag='#bsasahi'} | |
"BS-TBS" {$hashtag='#bstbs'} | |
"BSジャパン" {$hashtag='#bsjapan'} | |
"BSフジ・181" {$hashtag='#bsfuji'} | |
"BS11イレブン" {$hashtag='#bs11'} | |
"BS12トゥエルビ" {$hashtag='#bs12'} | |
#地デジ | |
"NHK総合1・東京" {$hashtag='#nhk'} | |
"NHKEテレ1東京" {$hashtag='#etv'} | |
"tvk1" {$hashtag='#tvk'} | |
"チバテレ1" {$hashtag='#chibatv'} | |
"日テレ1" {$hashtag='#ntv'} | |
"テレビ朝日" {$hashtag='#tvasahi'} | |
"TBS1" {$hashtag='#tbs'} | |
"テレビ東京1" {$hashtag='#tvtokyo'} | |
"フジテレビ" {$hashtag='#fujitv'} | |
"TOKYO MX1" {$hashtag='#tokyomx'} | |
"TOKYO MX2" {$hashtag='#tokyomx'} | |
#その他 | |
default {$hashtag="$_"} | |
} | |
#====================content==================== | |
#録画用アプリの起動数を取得 | |
$RecCount=(Get-Process -ErrorAction 0 'EpgDataCap_bon').Count | |
#DateTime型整形 | |
$Duration=(([DateTime]$env:StartTime).AddSeconds($env:DurationSecond)).ToString("HH:mm") | |
$Start=([DateTime]$env:StartTime).ToString("yy/MM/dd (ddd) HH:mm") | |
#内容 | |
$env:content=@" | |
$Start~$Duration | |
$env:Title | |
$hashtag | |
同時録画数:$RecCount | |
"@ | |
#====================Twitter==================== | |
&"$ruby_path" "$tweet_rb_path" | |
#====================Discord==================== | |
#オブジェクト作成 | |
$payload=[PSCustomObject]@{ | |
content = $env:content | |
} | |
#JSONに変換 | |
$payload=($payload | ConvertTo-Json) | |
#Byte型に変換 | |
$payload=[System.Text.Encoding]::UTF8.GetBytes($payload) | |
#投稿 | |
Invoke-RestMethod -Uri $hookUrl -Method Post -Body $payload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment