This twitter script can currently tweet the selected user once they tweet, but instead of actually replying underneath the tweet, it tweets it as a standalone new tweet. How can I get it to actually reply instead of make a new tweet? I'm using Twit API: https://github.com/ttezel/twit
Here's what I have:
console.log('The bot is starting');
var Twit = require('twit');
var config = require('./config');
var T = new Twit(config);
//Setting up a user stream
var stream = T.stream('user');
stream.on('tweet', tweetEvent);
function tweetEvent(eventMsg) {
var replyto = eventMsg.user.screen_name;
var text = eventMsg.text;
var from = eventMsg.user.screen_name;
console.log(replyto + ' '+ from);
if (replyto =='other user's handle') {
var newtweet = '@' + from + ' Hello!';
tweetIt(newtweet);
}
}
function tweetIt(txt) {
var tweet = {
status: txt
}
T.post('statuses/update', tweet, tweeted);
function tweeted(err, data, response) {
if (err) {
console.log("Something went wrong!");
} else {
console.log("It worked!");
}
}
}