forked from malfynnction/AltText-Tweeter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
32 lines (27 loc) · 882 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
32
const TwitterP = require('twitter')
const keys = require('./keys')
const sendTweet = require('./send-tweet')
const getReplyText = require('./get-reply-text')
const getTweet = require('./get-tweet')
const Twitter = new TwitterP(keys)
Twitter.stream('statuses/filter', { track: '@get_altText' }, function (stream) {
stream.on('data', (broken_tweet) => {
const mentioning_id = broken_tweet.id_str
const mentioning_user = broken_tweet.user.screen_name
getTweet(mentioning_id).then((tweet) => {
getReplyText(tweet)
.then((reply) => {
if (reply && reply.length > 0) {
sendTweet(reply, mentioning_id, mentioning_user)
}
})
.catch((err) => console.error(err))
})
stream.on('error', function (err) {
console.log(err)
})
})
stream.on('error', function (err) {
console.log(err)
})
})