我有一个可以正常运行的 Twitter 机器人。当某人回复我时,即 @myTwitterHandle 是推文中的第一件事时,它会补充他们。以下代码允许我回复他们:
\n\nfunction tweetEvent(tweet) {\n\n // Who is this in reply to?\n var reply_to = tweet.in_reply_to_screen_name;\n // Who sent the tweet?\n var name = tweet.user.screen_name;\n // What is the text?\n var txt = tweet.text;\n\n // Ok, if this was in reply to me\n // Replace myTwitterHandle with your own twitter handle\n console.log(reply_to, name, txt);\n if (reply_to === \'myTwitterHandle\') {\n\n \xc2\xa6 // Get rid of the @ mention\n \xc2\xa6 txt = txt.replace(/@selftwitterhandle/g, \'\');\n\n \xc2\xa6 // Start a …Run Code Online (Sandbox Code Playgroud)