rhiever / TwitterFollowBot

A Python bot that automates several actions on Twitter, such as following users and favoriting tweets.
GNU General Public License v3.0
1.31k stars 447 forks source link

Method for favoriting a tweet and then following user #64

Closed kennethjmyers closed 9 years ago

kennethjmyers commented 9 years ago

Created a new method, auto_fav_then_follow, which combines auto_fav and auto_follow into one request.

Also updated the readme

rhiever commented 9 years ago

Thank you @kenncann! I'm going to have to give this merge some thought. I'm a bit nervous that merging code like this will lead to code bloat, e.g., next we'll have a "auto reply then follow" method and so on. At the moment I think I'd prefer to keep these methods separate, although I'm open to being convinced otherwise.

kennethjmyers commented 9 years ago

That makes sense @rhiever, I had thought about reorganizing some of the code to put most of auto_follow in a separate method so that the parts that I duplicated weren't repeated but I can see that adding up fast. I'll probably continue to make edits that suit my needs and make pull requests every now and then to see if you like it

rhiever commented 9 years ago

I wonder if we can abstract the code base such that the auto_follow, auto_fav, etc. methods act on the direct result of the search tweets function rather than calling the search tweets function themselves. That way, a auto_fav_then_follow function would look like (pseudocode):

searched_tweets = search_tweets('phrase')
auto_fav(searched_tweets)
auto_follow(searched tweets)

Similarly, the auto_fav function that the user calls could be a wrapper for the underlying functions:

def auto_fav_phrase(phrase, count):
    searched_tweets = search_tweets(phrase)
    auto_fav(searched_tweets)

That would prevent the code duplication that we see in this PR.

Is that a rework you'd be willing to hack at? Otherwise, I'll add it as an enhancement issue for future work.

kennethjmyers commented 9 years ago

Yeah that makes a lot of sense I'll work on that

rhiever commented 9 years ago

:+1:

kennethjmyers commented 9 years ago

Ok @rhiever, I've made the updates you suggested, let me know what you think!

rhiever commented 9 years ago

Great work! Thank you. :+1:

rhiever commented 9 years ago

Gah, sorry about this @kenncann. When I was reviewing this code to send out an update, I realized that the API completely changed with this code change. All the current users would have to change their existing code to accommodate the new API if they upgraded to the latest version, and I'd imagine that would cause quite a few problems.

I think the solution to this would be to switch the functions around: auto_fav, auto_follow, etc. still accept the phrase, count, result_type, etc. as inputs. Those functions would execute the search_tweets then pass the searched_tweets list to underlying auto_fav_tweet_list, auto_follow_tweet_list, etc. functions.

That would then easily allow the addition of auto_fav_then_follow functions because they would be calling the underlying auto*_list functions.