Skip to content

Instantly share code, notes, and snippets.

@megaya
Created January 21, 2022 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save megaya/9a235251411c8226b701ddd4e5118c92 to your computer and use it in GitHub Desktop.
Save megaya/9a235251411c8226b701ddd4e5118c92 to your computer and use it in GitHub Desktop.
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