Giter Site home page Giter Site logo

Suggestions about twitterfollowbot HOT 5 OPEN

rhiever avatar rhiever commented on September 8, 2024
Suggestions

from twitterfollowbot.

Comments (5)

selimanac avatar selimanac commented on September 8, 2024

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.

rhiever avatar rhiever commented on September 8, 2024

👍 Can you please submit this code as a pull request once you've tested it a little bit?

from twitterfollowbot.

rhiever avatar rhiever commented on September 8, 2024

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.

Loaft avatar Loaft commented on September 8, 2024

Anyway I can retweet a users latest tweets? Or only retweet/fav a users timeline?

from twitterfollowbot.

rhiever avatar rhiever commented on September 8, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.