Option Explicit Dim arg ,fso ,regEx ,tempFile ,tempLine ,strChHashTag ,strRecState ,strTweet ,WshShell Set arg = WScript.Arguments Set fso = CreateObject("Scripting.FileSystemObject") Set regEx = New RegExp Set WshShell = WScript.CreateObject("WScript.Shell") '処理振り分け Select Case Len(arg(0)) Case 2 RecLog '録画開始・終了 Case 3 Watching '視聴中 Case 4 RecSet '録画予約と時間調整 End Select Set arg = Nothing Set tempFile = Nothing '録画予約と時間調整  引数の例 "録画予約" "予約タイトル名" "11/25" "21:00" "22:00" "twrb12345678" "放送局名" Sub RecSet() Set tempFile = fso.OpenTextFile("tvrock.log2") 'このVBSファイルをTvRock設定の作業フォルダ以外に置いた場合は各自の環境に合わせて下さい tempLine = tempFile.ReadLine tempFile.Close regEx.Pattern = "^\[\d\d/\d\d/\d\d \d\d:\d\d:\d\d (.+?)\]:.+" strTweet = regEx.Replace(tempLine, arg(0) & " [" & arg(2) & " " & arg(3) & "〜" & arg(4) & " " & arg(6) & "] " _ & arg(1) & " [TvRock V$1 " & Left(arg(5),Len(arg(5)) - 4) & " " & arg(5) & "]") TweetExecute End Sub '視聴中  引数の例 "視聴中" "タイトル名" "twrb12345678" "ジャンル名" Sub Watching() If arg.Count >= 4 Then ' If arg(3) = "ニュース/報道" Then Exit Sub '視聴中のツイートしないジャンルの場合、行頭の「'」を削除 ' If arg(3) = "スポーツ" Then Exit Sub '同上 ' If arg(3) = "ドラマ" Then Exit Sub '同上 ' If arg(3) = "音楽" Then Exit Sub '同上 ' If arg(3) = "バラエティー" Then Exit Sub '同上 ' If arg(3) = "映画" Then Exit Sub '同上 ' If arg(3) = "アニメ/特撮" Then Exit Sub '同上 ' If arg(3) = "情報/ワイドショー" Then Exit Sub '同上 ' If arg(3) = "ドキュメンタリー/教養 " Then Exit Sub '同上 ' If arg(3) = "劇場/公演" Then Exit Sub '同上 ' If arg(3) = "趣味/教育" Then Exit Sub '同上 End If If arg.Count = 5 Then ChTag '放送局名の"%5"が末尾にあれば放送局名ハッシュタグを付加 strTweet = "視聴中 " & arg(1) & " #" & Left(arg(2),Len(arg(2)) - 4) & " #" & arg(2) & strChHashTag TweetExecute End Sub '録画開始・終了  引数の例(ハッシュタグまでは必須) "終了" "T2" "予約タイトル名" "twrb12345678" "放送局名" "ファイル名" "アニメ/特撮" Sub RecLog() '指定ジャンルではツイートしない場合の処理 If arg.Count = 7 Then ' If arg(6) = "ニュース/報道" Then Exit Sub '録画開始・終了のツイートしないジャンルの場合、行頭の「'」を削除 ' If arg(6) = "スポーツ" Then Exit Sub '同上 ' If arg(6) = "ドラマ" Then Exit Sub '同上 ' If arg(6) = "音楽" Then Exit Sub '同上 ' If arg(6) = "バラエティー" Then Exit Sub '同上 ' If arg(6) = "映画" Then Exit Sub '同上 ' If arg(6) = "アニメ/特撮" Then Exit Sub '同上 ' If arg(6) = "情報/ワイドショー" Then Exit Sub '同上 ' If arg(6) = "ドキュメンタリー/教養 " Then Exit Sub '同上 ' If arg(6) = "劇場/公演" Then Exit Sub '同上 ' If arg(6) = "趣味/教育" Then Exit Sub '同上 End If WScript.Sleep 3000 '念のためtvrock.log2の更新を待つ(3秒) Set tempFile = fso.OpenTextFile("tvrock.log2") 'このVBSファイルをTvRock設定の作業フォルダ以外に置いた場合は各自の環境に合わせて下さい Do Until tempFile.AtEndOfStream tempLine = tempFile.ReadLine If InStr(tempLine, "[" & arg(1) & "]番組「" & arg(2) & "」 録画" & arg(0)) <> 0 Then Exit Do Loop tempFile.Close If InStr(tempLine, "[" & arg(1) & "]番組「" & arg(2) & "」 録画" & arg(0)) = 0 Then Exit Sub regEx.Pattern = "^.*:\d\d (.+?)\]:\[.+?Sig=(.+?), Bitrate=(.+?)Mbps, Drop=(.+?), Scrambling.+? BcTimeDiff=(.+?)sec, TimeAdj=(.+?)sec, CPU.*" strRecState = regEx.Replace(tempLine, "Sg$2,Br$3,Dr$4,Td$5,Ta$6,TvRock V$1 " & Left(arg(3),Len(arg(3)) - 4) & " " & arg(3) & "]") Select Case arg.Count Case 4 strTweet = "録画" & arg(0) & " " & arg(2) & " [" & strRecState 'Ver 0.9t8準拠 Case 5 strTweet = "録画" & arg(0) & " " & arg(2) & " [" & arg(4) & "," & strRecState '放送局名追加 Case Else ' strTweet = "録画" & arg(0) & " " & arg(5) & " [" & arg(4) & "," & strRecState 'ファイル名の場合 regEx.Pattern = "(.+?)_\d{6}.*" 'ファイル名の末尾の「_年月日…」を取り除く ' regEx.Pattern = "(.+?)_" & arg(4) & ".*" 'ファイル名の末尾の「_放送局名…」を取り除く strTweet = "録画" & arg(0) & " " & regEx.Replace(arg(5), "$1") & " [" & arg(4) & "," & strRecState 'ファイル名を置換した場合 End Select TweetExecute End Sub 'ツイートを投稿 Sub TweetExecute() strTweet = Replace(strTweet, "草・剛" ,"草g剛") strTweet = Replace(strTweet, "・田延彦" ,"田延彦") strTweet = Replace(strTweet, "・橋大輔" ,"橋大輔") strTweet = Replace(strTweet, "・永英明" ,"コ永英明") strTweet = Replace(strTweet, "宮・あおい" ,"宮アあおい") WshShell.Run "C:\TweetConsole\twtcnsl.exe /t " & strTweet , 0, True 'パスは各自の環境に合わせて下さい Set WshShell = Nothing End Sub '放送局名ハッシュタグ Sub ChTag Dim tempCh ,tempTag ,i tempCh = Array("NHK総合", "NHK教育", "日本テレビ", "テレビ朝日", "TBSテレビ", "テレビ東京", "フジテレビ", "MXテレビ" ,_ "NHK衛星第一", "NHK衛星第二", "NHKハイビジョン") tempTag = Array("nhk", "etv", "ntv", "tvasahi", "tbs", "tvtokyo", "fujitv", "mxtv", "bs1", "bs2", "bshi") For i=LBound(tempCh) To UBound(tempCh) If InStr(arg(4),tempCh(i)) <> 0 Then Exit For Next strChHashTag = " #" & tempTag(i) End Sub