Created
January 21, 2022 03:50
-
-
Save megaya/9a235251411c8226b701ddd4e5118c92 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
const Alexa = require('ask-sdk-core'); | |
const { | |
TwitterApi | |
} = require('twitter-api-v2'); | |
const twClient = new TwitterApi({ | |
appKey: 'keyをここに入れる', | |
appSecret: ‘keyをここに入れる ', | |
accessToken: 'keyをここに入れる', | |
accessSecret: 'keyをここに入れる', | |
}); | |
const LaunchRequestHandler = { | |
canHandle(handlerInput) { | |
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest'; | |
}, | |
handle(handlerInput) { | |
return twClient.v1.userTimelineByUsername(‘megaya0403’).then((value) => { | |
let allTweet = '' | |
for (const t of value.tweets) { | |
if (t.retweeted_status) { | |
continue | |
} | |
allTweet += t.full_text | |
allTweet += '\n' | |
} | |
return handlerInput.responseBuilder.speak(allTweet).getResponse(); | |
}) | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment