Giter Site home page Giter Site logo

gazugafan / chirp Goto Github PK

View Code? Open in Web Editor NEW
21.0 3.0 1.0 33 KB

Automatically follow Twitter users and later unfollow them if they don't follow you back. Easily grow your Twitter audience!

License: MIT License

PHP 100.00%
twitter bot php follow automatic automation command-line cli php7 twitter-api

chirp's Introduction

Chirp

A command-line tool to automatically follow Twitter users and later unfollow them if they don't follow you back. Use it to easily grow your Twitter audience.

Requirements

  • PHP 7.1.3+
  • Composer

Installation

  • Clone this repository on your server
  • Run composer install
  • Run php chirp to test that it's working and see a list of commands
  • Add the following cron task to run every minute (the actual schedule is managed in the app)...
* * * * * php /INSTALL/PATH/chirp schedule:run >> /dev/null 2>&1

Setup

  • You'll need to have a Twitter app created, along with a personal access token to authenticate to the Twitter API. You might be able to do this from the Twitter app manager, but this is being deprecated soon. If you can't do it there, you'll probably need to apply for a developer account.
  • Rename .env.example to .env
  • Open .env and fill in the OAuth details from the Twitter app you created. You'll need the app's consumer key and secret, along with a personal access token and secret.
  • Run php chirp test:twitter to test that we can authenticate to the Twitter API.

Usage

Run php chirp add:user <username> to add the followers of the specified user to a locally stored list. Do this as many times as you'd like to grow this list of users. Duplicates are automatically removed, along with users you already follow.

After this, chirp will periodically follow and mute a random user from this list. Muted users don't appear in your timeline, but otherwise act as normal follows. The hope is that some of these users will follow you back soon! If they do, consider unmuting them if you'd like to see their tweets.

Chirp keeps track of who it's followed for you, along with when it followed them. If one of these users hasn't followed you back after 10 days, chirp will eventually unfollow them.

Rate Limits

Out of the box, chirp is not scheduled to run fast enough to come close to hitting any rate limits. However, you can modify this schedule to run as fast as you'd like. In this case, chirp attempts to proactively respects Twitter's rate limits.

Some of Twitter's API methods always respond with rate limit data--telling us how many requests you have remaining and when you'll get more. For these API methods, chirp remembers the rate-limit information and will not attempt an API request if you have no more attempts remaining. Chirp does NOT simply make API requests until the API starts responding with rate limit errors. It knows to stop ahead of time, and it knows when it can start again.

There are other Twitter API methods that do NOT respond with rate limit data. These include following users, muting users, and unfollowing users. Twitter is a little ambiguous about the rate limits on these, but from what I can tell they each have their own 1000 daily request limit. By default, chirp is configured to proactively limit these requests to 990 per day to be sure to stay under. You can adjust this in config/app.php.

In any case, if Twitter ever responds with a rate limit error, chirp will hold off on that type of request for 24 hours just to be safe.

Schedule

By default, chirp is scheduled to run once every 5 minutes on weekdays between 10am-4pm CST. To make things a little fuzzy, chirp will wait a random number of seconds (up to 250, or about 4 minutes) everytime it runs. Each time chirp runs, it will...

  1. Attempt to follow 1 random user from your list of users to follow, and
  2. Attempt to unfollow 1 random user from the list of users chirp followed over 10 days ago who have not followed you back. (you can change how many days to wait for a follow back in config/app.php)

You can modify this schedule in app/Commands/WorkCommand.php. To make it go really fast, you can have each run perform multiple follows/unfollows. See the end of the file for more information.

Log

You can review the log of what chirp did when it was running on schedule in the chirp.log file.

Other Commands

The main command you'll use is add:user, which adds the followers of a user to the list of users chirp will attempt to follow. If you'd like, you can review this list using the list:to_follow command (though it lists user IDs--not screen names).

Once you've setup the cron, chirp will run the process:work command on schedule, which attempts to follow 1 user and unfollow 1 user.

You can also manually follow a user from the list of users you want to follow using the process:follow command. Likewise, you can manually unfollow a user who hasn't followed you back using the process:unfollow command.

To see all of the available commands, run php chirp. To get more help on a specific command, run php chirp help <command>. For example: php chirp help add:user will tell you how to use the add:user command.

Storage

Chirp just uses simple local file storage to remember who it has followed and such--no database server required! These files are located in the storage folder.

chirp's People

Contributors

gazugafan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

gregorycoleman

chirp's Issues

helper.php error

hello @gazugafan

I was trying out the app you have created as it seems to be well thought out, especially since you have taken into account the rate-limiting!

I do have a problem though. when I run php chirp I get this parse error:

Parse error: syntax error, unexpected '?' in /home/proje485/public_html/iaddicshelters.net/BOT/vendor/laravel-zero/foundation/src/Illuminate/Foundation/helpers.php on line 494

I have googled for a solution and it seemed it may be related to php version error. However; I am using PHP Version 7.2.16

Any ideas what may be getting in the way. I am not a programmer just trying my best to get some tools in place to help my efforts! Thanks Rich

Variables

He Ken:

Quick question if I may. Reading through your documentation in the WorkCommand file I see where you indicate the schedule defaults to 5 minutes and a fuzzy of about 4.2 minutes. You indicate that the schedule can be changed to lengthen or shorten the default 5 minutes and I see it here: lines 86-92.

	$schedule->command(static::class, ['250', '1'])
		->withoutOverlapping()
		->appendOutputTo('chirp.log')
		**->everyFiveMinutes()**
		->weekdays()
		->timezone('US/Central')
		->between('10:00', '16:00')

So if I wanted to change the schedule to run once every 7 minutes, what would I for
->everyFiveMinutes()

Do I enter 7 for 7 minutes or 7/5 or 1.4 minutes? id the variable really Every Five Minutes?

secondly, how do I specify Monday through Saturday?

lastly, what is the withoutOverlapping()?

Thanks much, Rich

Question on timing

Hi Ken, I was reviewing the chirp.log and notice that the pattern is very consistent.

There is some ambiguity in the log in that it doesn't say the time when a twitter account was actually sent to Twitter so I need to ask: are the times in the chirp.log file the window in which the user is processed or the time stamp of the actual user being sent to Twitter?

If it is the later then the time is not taking into account the fuzzy part of the equation because it is too regular of a pattern.

If it is the former, then a timestamp for when the user id is actually sent to twitter would be beneficial.

Also, if the times recorded are the window of processing then I take it the fuzzy logic is a subtraction number from 5 minutes, not a plus or minus amount from 5 minutes. Here too the 5 minutes interval seems too regular for any addition to take place.

Am I understanding this right?

Thanks, Rich

2019-04-04 11:29:12 UTC: Starting work...
Followed AquQQQQQQsGirl06!
There aren't any users to unfollow
2019-04-04 11:29:12 UTC: Finished work!
2019-04-04 11:34:12 UTC: Starting work...
Followed JQQQQQQ7!
There aren't any users to unfollow
2019-04-04 11:34:12 UTC: Finished work!
2019-04-04 11:39:11 UTC: Starting work...
Followed wQQQQQQQr!
There aren't any users to unfollow
2019-04-04 11:39:12 UTC: Finished work!
2019-04-04 11:44:11 UTC: Starting work...
Followed cQQQQQQQQcarr!
There aren't any users to unfollow
2019-04-04 11:44:12 UTC: Finished work!
2019-04-04 11:49:11 UTC: Starting work...
Followed allisQQQQorres!
There aren't any users to unfollow
2019-04-04 11:49:11 UTC: Finished work!
2019-04-04 11:54:11 UTC: Starting work...
Followed da2QQQQQQ861!
There aren't any users to unfollow
2019-04-04 11:54:12 UTC: Finished work!
2019-04-04 11:59:11 UTC: Starting work...
Followed nQQQQQQQQQQQQdru!
There aren't any users to unfollow
2019-04-04 11:59:11 UTC: Finished work!
2019-04-04 12:04:12 UTC: Starting work...
Followed JoQQQQQQQQQel7!
There aren't any users to unfollow
2019-04-04 12:04:12 UTC: Finished work!
2019-04-04 12:09:11 UTC: Starting work...
Followed SQQasi!
There aren't any users to unfollow
2019-04-04 12:09:11 UTC: Finished work!

1 Question, 1 item worth noting

Hi Ken,

Question: Once the process to import an account's followers has started how do I kill the process.

Observation: I a large account is selected to capture the followers, a rate limit is immediately applied and it doesn't look like any id's are captured so that when the process restarts it picks up where it left off.

My use case was to be this: We run a charity called Shelter The World that relies on sponsors from real estate professionals. Who better to harness than the followers of the national real estate association...

Apparently, there are too many id's to capture. The to_follow file never gets written to (or created if this is the first attempt at importing)

twitter account I tried: nardotrealtor
size: 301K

Respecting rate limit on the followers_ids method. This will clear at Saturday, Mar 30, 2019 @ 03:19pm UTC
proje485@m48 [~/public_html/sheltertheworldorg/real-estate-bot]# Respecting rate limit on the followers_ids method. This will clear at Saturday, Mar 30, 2019 @ 03:19pm UTC

Thanks, Rich

Count = ? not working

Hello again @gazugafan ~ I have the script running and it is cycling through a list I set and all seems to be well except one point. The script is not recognizing a change to the count variable. I changed the value from 1 to 3 but every time the script runs it only increments the followers by 1 not 3 as expected.

// Changed count from 1 to 3 -- RMG 3/28/2019 protected $signature = 'process:work {fuzz=0 : If specified, we\'ll wait up to this random number of seconds before each follow/unfollow } {count=3 : The number of follows/unfollows to attempt this time }';

Also: are you familiar with a script that would move all muted contacts to a list. As I am thinking through how this is working I would offer that the main follower is associated with a topic (why else follow their followers) so muting them is nice ( I like that feature) but adding them to a list would be stellar!

I see I am the only user that has commented up to this point. Are you interested in hearing a users perspective or was mainly intended to be a script you intended to use personally? If you "need or want" ideas I have a few to offer. If not, no worries...I love the throttling of the script which separates you from all others!

Thanks, Rich

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.