Comments (5)
Not sure if it's correct or not. Don't try to retweet multiple times:
def get_do_not_retweet_tweet(self):
"""
Returns list of current retweets.
"""
if not os.path.isfile(self.BOT_CONFIG["TWEETS_FILE"]):
with open(self.BOT_CONFIG["TWEETS_FILE"], "r") as out_file:
out_file.write("")
do_not_retweet_tweet = set()
dnrt_list = []
with open(self.BOT_CONFIG["TWEETS_FILE"]) as in_file:
for line in in_file:
dnrt_list.append(int(line))
do_not_retweet_tweet.update(set(dnrt_list))
del dnrt_list
return do_not_retweet_tweet
def auto_rt(self, q, count=100, result_type="recent"):
"""
Retweets tweets that match a phrase (hashtag, word, etc.).
"""
result = self.search_tweets(q, count, result_type)
do_not_user_retweet = self.get_do_not_retweet_list()
do_not_retweet_tweet = self.get_do_not_retweet_tweet()
for tweet in result["statuses"]:
if tweet["id"] not in do_not_retweet_tweet:
print("TwittID: %s" % tweet["id"])
try:
# don't retweet your own tweets
if tweet["user"]["screen_name"] == self.BOT_CONFIG["TWITTER_HANDLE"]:
continue
if tweet["user"]["id"] not in do_not_user_retweet:
result = self.TWITTER_CONNECTION.statuses.retweet(id=tweet["id"])
with open(self.BOT_CONFIG["TWEETS_FILE"], "a") as out_file:
out_file.write(str(tweet["id"]) + "\n")
print("retweeted: %s" % (result["text"].encode("utf-8")))
# when you have already retweeted a tweet, this error is thrown
except TwitterHTTPError as e:
# quit on rate limit errors
if "rate limit" in str(e).lower():
print("You have been rate limited. Wait a while before running the bot again.")
return
print("error: %s" % (str(e)))
from twitterfollowbot.
👍 Can you please submit this code as a pull request once you've tested it a little bit?
from twitterfollowbot.
Regarding
Improving Rate Limit: Rate Limit returns how long you should wait as time format. This is complex i know. Just an idea… Don't break the script, wait until limit and continue….
I've never actually looked in detail how rate limiting works on the Twitter API. And do all actions equally count toward the API? I've seen times when I was rate limiting for following users but could still search tweets and favorite them.
from twitterfollowbot.
Anyway I can retweet a users latest tweets? Or only retweet/fav a users timeline?
from twitterfollowbot.
@Loaft: That's currently not implemented in the bot.
Honestly, I'm unsure about implementing auto-messaging features because that leads to very annoying, spammy messages being sent out all the time.
from twitterfollowbot.
Related Issues (20)
- Need help with installation please HOT 1
- auto_unfollow_nonfollowers() crashes for certain suspended user HOT 4
- Why my already-followed.txt is empty HOT 1
- twitterfollowbot 2.0.2 requires twitter==1.17.0, which is not installed. HOT 1
- Erreur de Syntaxe detectées dans les clés API
- probleme lors del'execution du programme python
- How to make the bot auto retweet the latest tweet? HOT 1
- Unfollow only X people that don't follow back?
- FYI - API wrapper methods out-dated; Project non-functional HOT 2
- Hello help me this problem not starting tweet bot
- dear author
- Automatically add users tweeting about something to one of your list
- Help with setting up a Twitter bot HOT 1
- a
- Can't run the bot HOT 2
- i am having this problem with irclib
- TwitterFollowBot
- T
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twitterfollowbot.