如何确保 Twitter 机器人不会多次转发同一条推文? [英] How do I make sure a twitter bot doesn't retweet the same tweet multiple times?

查看:52
本文介绍了如何确保 Twitter 机器人不会多次转发同一条推文?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 Python 编写一个简单的 Twitter 机器人,想知道是否有人可以为我回答和解释这个问题.

I'm writing a simple Twitter bot in Python and was wondering if anybody could answer and explain the question for me.

我可以发推文,但我还没有让机器人转推任何人.我害怕多次发布用户的推文.我计划让我的机器人仅基于 Windows 计划任务运行,所以当脚本运行(例如)第三次时,我如何获取它以便脚本/机器人不再转发推文?

I'm able to make Tweets, but I haven't had the bot retweet anyone yet. I'm afraid of tweeting a user's tweet multiple times. I plan to have my bot just run based on Windows Scheduled Tasks, so when the script is run (for example) the 3rd time, how do I get it so the script/bot doesn't retweet a tweet again?

澄清我的问题:假设有人在下午 5:59 发推文#computer".现在我的推特机器人应该转发任何包含 #computer 的推文.假设当机器人在下午 6:03 运行时,它会找到该推文并转发它.但是当机器人在下午 6 点 09 分再次运行时,它会再次转发同一条推文.我如何确保它不会转发重复的推文?

To clarify my question: Say that someone tweeted at 5:59pm "#computer". Now my twitter bot is supposed to retweet anything containing #computer. Say that when the bot runs at 6:03pm it finds that tweet and retweets it. But then when the bot runs again at 6:09pm it retweets that same tweet again. How do I make sure that it doesn't retweet duplicates?

我应该创建一个单独的文本文件并添加推文的 ID 并在每次机器人运行时通读它们吗?我一直无法找到有关此问题的任何答案,也不知道有效的检查方法.

Should I create a separate text file and add in the IDs of the tweets and read through them every time the bot runs? I haven't been able to find any answers regarding this and don't know an efficient way of checking.

推荐答案

Twitter 的设置使得您不能多次转发相同的内容.因此,如果您的机器人收到这样的推文,它将被 API 重定向到错误 403 页面.您可以通过将脚本每次运行之间的时间减少到大约一分钟来测试此策略;这将生成错误 403 链接,因为当前的推文提要保持不变.

Twitter is set such that you can't retweet the same thing more than once. So if your bot gets such a tweet, it will be redirected to an Error 403 page by the API. You can test this policy by reducing the time between each run by the script to about a minute; this will generate the Error 403 link as the current feed of tweets remains unchanged.

这篇关于如何确保 Twitter 机器人不会多次转发同一条推文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆