0
我有一个功能完整的twitter bot。当他们回复我时,它补充了某人,这是@myTwitterHandle是推文中的第一件事。下面的代码可以让我回应他们:如何使用Twitter API回应提及
function tweetEvent(tweet) {
// Who is this in reply to?
var reply_to = tweet.in_reply_to_screen_name;
// Who sent the tweet?
var name = tweet.user.screen_name;
// What is the text?
var txt = tweet.text;
// Ok, if this was in reply to me
// Replace myTwitterHandle with your own twitter handle
console.log(reply_to, name, txt);
if (reply_to === 'myTwitterHandle') {
¦ // Get rid of the @ mention
¦ txt = txt.replace(/@selftwitterhandle/g, '');
¦ // Start a reply back to the sender
¦ var reply = "You mentioned me! @" + name + ' ' + 'You are super cool!';
¦ console.log(reply);
¦ // Post that tweet!
¦ T.post('statuses/update', { status: reply }, tweeted);
}
}
我只想每当有人@mentions我的地方,在他们的鸣叫的身体发出完全相同的答复。我正在使用Node.js和twit api client。
完美工作,感谢你啊! – JHS
答复已发送,但未通知给用户,也未显示在他们的推特线程中。看到这个问题:https://twittercommunity.com/t/automated-replies-are-not-being-notified-to-users-nor-in-reply-thread/79994 –
@SantoshKumar不知道这是否有帮助,但我是使用Twit包与上面的代码在这里找到:https://github.com/ttezel/twit。另见这里:http://stackoverflow.com/a/39028879/5884189 – filmplane