Created
March 11, 2018 13:10
-
-
Save mokapyo/e9086d14eb6a28478721c61676ea71e7 to your computer and use it in GitHub Desktop.
GoogleHome用旦那監視アプリ
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
var googlehome = require('google-home-notifier'); | |
var twitter = require('twitter'); | |
var language = 'ja'; | |
// 取得したTwitter API用の設定--- | |
var client = new twitter({ | |
consumer_key: 'piyo', | |
consumer_secret: 'piyopiyo', | |
access_token_key: 'piyopiyopiyo', | |
access_token_secret: 'piyopiyopiyopiyo', | |
}); | |
// 同一ネットワーク内からGoogle Homeを見つけてくる | |
googlehome.device('Google Home', language); | |
var params = {screen_name: '!!wife!!'}; // 監視アカウント名 | |
client.get('statuses/user_timeline', params, function(error, tweets, response) { | |
if (!error) { | |
// Tweet情報からユーザー固有IDを取得 | |
var user_id = tweets[0].user.id_str; | |
// ストリーミングで監視するオプション | |
var option = {follow: user_id}; | |
client.stream('statuses/filter', option, function(stream){ | |
stream.on('data',function(data){ | |
console.log(data.text); | |
// 喋る | |
googlehome.notify(data.text, function(res) { | |
console.log(res); | |
}); | |
}) | |
}) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment