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

How to add delay between actions. #69

Closed rl421403 closed 9 years ago

rl421403 commented 9 years ago

This is my script.

from TwitterFollowBot import TwitterBot

my_bot = TwitterBot("config.txt")

my_bot.auto_follow("wordpress", count=10)

This makes me follow 10 users. And I want to add delay between these follow actions or any other action.

How can I add that delay.

EDIT:

And what are these FOLLOW_BACKOFF_MIN_SECONDS:10 & FOLLOW_BACKOFF_MAX_SECONDS:60. What exactly both of these do?

rhiever commented 9 years ago

FOLLOW_BACKOFF_MIN_SECONDS:10 and FOLLOW_BACKOFF_MAX_SECONDS:60 in the config.txt tell the bot to wait a random amount of seconds in between those two numbers between every follow, fav, etc. action. That basically implements the delay you're looking for.

rl421403 commented 9 years ago

That's nice to know but I don't think it is working properly. Because when I tried above script, it added followers instantly without even waiting for 10-60 seconds. Command took only like less then 1 sec.

I have been using default options in my config file.

FOLLOW_BACKOFF_MIN_SECONDS:10
FOLLOW_BACKOFF_MAX_SECONDS:60

I have Python 3 installed on Ubuntu server.

rhiever commented 9 years ago

That's really strange. I swear the latest version on PyPi has that functionality.

I just did a re-upload to PyPi with v2.0.2. Please try a pip --upgrade and let me know if the wait functionality works now. It's working fine on my server.

rl421403 commented 9 years ago

That could be the issue. I have Python 3.4.0 installed and pip 1.5.4. I tried upgrading pip but it's keep installing 1.5.4.

and pip --upgrade returns invalid command.

rhiever commented 9 years ago

Try: pip install --upgrade TwitterFollowBot

rl421403 commented 9 years ago

Oh you mean upgrade TwitterFollowBot. I thought you are asking to upgrade about pip. Anyway, I upgraded TwitterFollowBot and strange thing happened. it started adding random delay.

Earlier when I executed my script, I got output like...

Followed 98918919
Followed 29382938
Followed 29389238

And it took less then a minute to follow 3 accounts but now it's seems to be working. This is the output I got.

Choosing time between 10 and 60 - waiting 11 seconds before action
Followed 98918919
Choosing time between 10 and 60 - waiting 44 seconds before action
Followed 29382938
Choosing time between 10 and 60 - waiting 53 seconds before action
Followed 29389238

Yep.. It's working great now. Thanks for your help. Really nice script.

rhiever commented 9 years ago

Great!

You can control the range of that delay with the FOLLOW_BACKOFF_MIN_SECONDS and FOLLOW_BACKOFF_MAX_SECONDS in your config.txt too.

If you want to remove the delay entirely, then simply remove those two entries in your config.txt.