-
Notifications
You must be signed in to change notification settings - Fork 18
/
bot.js
28 lines (22 loc) · 859 Bytes
/
bot.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
const { auth, postReplyWithMedia, postReply } = require('./config.js');
const client = auth();
client.stream('statuses/filter', { track: '#FilterMe' }, function (stream) {
console.log("Searching for tweets...");
// when a tweet is found
stream.on('data', function (tweet) {
console.log("Found one!");
console.log("Recieved tweet reading...", tweet.text);
// check if tweet contains some media
if (tweet.media_url) {
console.log("Replying to tweet with video.");
postReplyWithMedia(client, "./sample-media/video.mp4", tweet);
} else {
console.log("Tweet didn't provide media. Replying with message.");
const message = "Oops, looks like you didn't provide a media file!";
postReply(client, message, tweet);
}
stream.on('error', function (error) {
console.log(error);
});
});
});