-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
26 lines (20 loc) · 798 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const Twitter = require('twit')
const TweetDeleter = require('./TweetDeleter.js')
const dayInMs = 24 * 60 * 60 * 1000
module.exports = function(context, done) {
const maxTweetAge = context.secrets.MAX_TWEET_AGE * dayInMs
const keybaseTweetId = context.secrets.KEYBASE_TWEET_ID
const twitterClient = new Twitter({
consumer_key: context.secrets.CONSUMER_KEY,
consumer_secret: context.secrets.CONSUMER_SECRET,
access_token: context.secrets.ACCESS_TOKEN,
access_token_secret: context.secrets.ACCESS_TOKEN_SECRET
})
const tweetDeleter = new TweetDeleter(twitterClient, maxTweetAge, keybaseTweetId)
tweetDeleter.run()
.then(deletedTweets => {
console.log(`Done. Deleted ${deletedTweets.length} tweets.`)
done(null, { deletedTweets })
})
.catch(done)
}