ntwitter
ntwitter copied to clipboard
Reply to a tweet
I see in the readme there is an example of how to publish a status update.
Is there any way to have a tweet look like a reply to a tweet from your stream, instead of just a plan status update?
Yep, similar thought. Implementing this would be great.
Hey @anthonywebb and @dezinezync,
This is actually achievable right now.
If you look at the code that makes up updateStatus, you'll see it actually takes a second parameter that is an Object of keys/values corresponding to the Twitter Rest API (look at status and include_entities - they're enabled by default here).
So, we actually would just need to pass in the in_reply_to_status_id
key and an ID of an existing status. To get that, we just need to set a local var to the tweet.id_str
, and then we can use that var as the value of the in_reply_to_status_id
value. From there, we just use that object as our second parameter in updateStatus
, and move our callback to the third param.
So, for example:
twit.stream('/status/filter', function(stream) {
stream.on('data', function (tweet) {
var reply_id = tweet.id_str;
twit.updateStatus(
"@connor hey how's it going?"
, {in_reply_to_status_id: reply_id}
, function(err, data) {
if (err) { console.log (err) }
}
)
}
}
^5's, Connor
+1 @connor - Worked for me!