-
Notifications
You must be signed in to change notification settings - Fork 6
/
app.js
31 lines (26 loc) · 860 Bytes
/
app.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
27
28
29
30
31
const TwitterP = require('twitter')
const keys = require('./keys')
const sendTweet = require('./lib/send-tweet')
const getReplyText = require('./lib/get-reply-text')
const getTweet = require('./lib/get-tweet')
const Twitter = new TwitterP(keys)
Twitter.stream('statuses/filter', { track: '@get_altText' }, function (stream) {
stream.on('data', (brokenTweet) => {
const mentioningTweetId = brokenTweet.id_str
const mentioningUsername = brokenTweet.user.screen_name
getTweet(mentioningTweetId)
.then(getReplyText)
.then((reply) => {
if (reply && reply.length > 0) {
sendTweet(reply, mentioningTweetId, mentioningUsername)
}
})
.catch((err) => console.error(err))
stream.on('error', (err) => {
console.log(err)
})
})
stream.on('error', (err) => {
console.log(err)
})
})