微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Node.js上的twit-创建Twitter线程时在tweet之间计时

如何解决Node.js上的twit-创建Twitter线程时在tweet之间计时

摘要

该项目:一个Twitter帐户,当有人发布某些关键字时,它会回复Twitter主题

问题

一切都按预期进行,但是突然我发现,在帐户回复用户后,Twitter消除了该线程。 (Twitter用“该推文不可用”灰色框替换了这些推文。)

代码

// Create Twitter Thread
const createThreadWithImages = async (requested_tweet,thread_array,callback) => {
    console.log("[*] Creating thread...")

    try{
        let lastTweetId = requested_tweet.id_str

        // Initial tweet content array
        const first_tweet_content = [
            ....
            'Some strings',....
        ]

        for (const tweet_img_array of thread_array){
            const random_text = first_tweet_content[Math.floor(Math.random() * first_tweet_content.length)]
            const tweet_from_thread = await T.post("statuses/update",{
                status: `@${requested_tweet.user.screen_name} ${random_text}`,in_reply_to_status_id: '' + lastTweetId,media_ids: tweet_img_array
            })

            lastTweetId = tweet_from_thread.data.id_str
        }

        console.log("[+] Thread completed.")
        callback()

    } catch(error){
        console.error("[-] Something went wrong when trying to create a thread: \n",error)
    }

}

我想做什么

在创建线程时,我想在每个tweet之间放置一个计时器,但是我无法弄清楚。当用户使用关键字发布推文时,我的代码几乎总是立即发布推文。因此,我怀疑Twitter将线程标记垃圾邮件

我尝试过的事情

  • 更改Twitter API令牌
  • 更改Twitter帐户
  • 使用Twit线程包
  • tweet_from_thread常量附近使用setTimeout

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。