|
1 | | -# GitBuddy-Bot |
2 | | -This bot allows you to automatically star repositories and follow users based on specific criteria, ensuring compliance with GitHub's Terms of Service. |
| 1 | +# GitHub Bot |
| 2 | + |
| 3 | +GitHub Bot is an automation tool designed to interact with GitHub's API. It allows you to automatically star repositories and follow users based on specific criteria. This tool ensures compliance with GitHub's Terms of Service by pacing its operations to avoid being flagged as spam. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Automatic Starring**: Automatically star repositories based on a set criteria (e.g., created in the last day, less than 4 stars). |
| 8 | +- **Automatic Following**: Follow users who own the repositories that meet the criteria. |
| 9 | +- **Undo Operations**: Unstar repositories and unfollow users to revert the operations. |
| 10 | +- **Rate Limit Awareness**: Checks and respects GitHub API rate limits to avoid being throttled. |
| 11 | +- **Graceful Shutdown**: Listens for shutdown signals to stop operations cleanly. |
| 12 | +- **Slow-Paced Operations**: Introduces delays between operations to comply with GitHub's anti-spam policies. |
| 13 | + |
| 14 | +## Working Principle |
| 15 | + |
| 16 | +1. **Rate Limit Check**: Before starting operations, the bot checks the current rate limit to ensure it doesn't exceed the allowed number of requests. |
| 17 | +2. **Fetch Repositories**: Searches for repositories created in the last day with less than 4 stars. |
| 18 | +3. **Process Repositories**: Stars the repositories and follows the owners with a delay between each operation to avoid spam. |
| 19 | +4. **Undo Operations**: Provides functionality to unstar repositories and unfollow users that were starred and followed during the bot's operations. |
| 20 | + |
| 21 | +## Installation |
| 22 | + |
| 23 | +1. **Clone the Repository**: |
| 24 | + ```sh |
| 25 | + git clone https://github.com/yourusername/github-bot.git |
| 26 | + cd github-bot |
| 27 | + ``` |
| 28 | + |
| 29 | +2. **Set Up Environment**: |
| 30 | + Ensure you have Java 11 or higher installed. Set the `GITHUB_TOKEN` environment variable with your GitHub Personal Access Token. |
| 31 | + ```sh |
| 32 | + export GITHUB_TOKEN=your_github_token |
| 33 | + ``` |
| 34 | + |
| 35 | +### Compiling in an IDE |
| 36 | + |
| 37 | +#### Visual Studio Code |
| 38 | + |
| 39 | +1. **Open Project**: |
| 40 | + - Open Visual Studio Code. |
| 41 | + - Open the cloned repository folder. |
| 42 | + |
| 43 | +2. **Install Extensions**: |
| 44 | + - Install the Java Extension Pack from the Extensions view (`Ctrl+Shift+X`). |
| 45 | + |
| 46 | +3. **Build and Run**: |
| 47 | + - Open the terminal in Visual Studio Code (`Ctrl+``). |
| 48 | + - Use the following command to build the project: |
| 49 | + ```sh |
| 50 | + ./gradlew build |
| 51 | + ``` |
| 52 | + - Run the project using the command: |
| 53 | + ```sh |
| 54 | + java -jar build/libs/github-bot.jar |
| 55 | + ``` |
| 56 | +
|
| 57 | +#### IntelliJ IDEA |
| 58 | +
|
| 59 | +1. **Open Project**: |
| 60 | + - Open IntelliJ IDEA. |
| 61 | + - Select "Open" and navigate to the cloned repository folder. |
| 62 | +
|
| 63 | +2. **Import Project**: |
| 64 | + - IntelliJ will detect the `build.gradle` file and prompt to import the project. Click "Import Gradle Project". |
| 65 | +
|
| 66 | +3. **Build and Run**: |
| 67 | + - Use the build tool window to execute `./gradlew build`. |
| 68 | + - Run the `GitHubBot` class by right-clicking on it and selecting "Run 'GitHubBot.main()'". |
| 69 | +
|
| 70 | +### Using the JAR Release |
| 71 | +
|
| 72 | +1. **Download the JAR**: |
| 73 | + - Go to the [Releases](https://github.com/yourusername/github-bot/releases) section of the repository. |
| 74 | + - Download the latest `.jar` release. |
| 75 | +
|
| 76 | +2. **Run the JAR**: |
| 77 | + ```sh |
| 78 | + java -jar path/to/github-bot.jar |
| 79 | + ``` |
| 80 | +
|
| 81 | +## Usage |
| 82 | +
|
| 83 | +### Method 1: Building and Running |
| 84 | +
|
| 85 | +1. **Build the Project**: |
| 86 | + ```sh |
| 87 | + ./gradlew build |
| 88 | + ``` |
| 89 | +
|
| 90 | +2. **Run the Bot**: |
| 91 | + ```sh |
| 92 | + java -jar build/libs/github-bot.jar |
| 93 | + ``` |
| 94 | +
|
| 95 | +### Method 2: Running the Compiled `.jar` File |
| 96 | +
|
| 97 | +1. **Download the Compiled `.jar` File**: |
| 98 | + If you already have the compiled `.jar` file, you can directly run it using the following command: |
| 99 | + ```sh |
| 100 | + java -jar github-bot.jar |
| 101 | + ``` |
| 102 | +
|
| 103 | +## Detailed Explanation |
| 104 | +
|
| 105 | +### Rate Limit Check |
| 106 | +
|
| 107 | +The bot first checks the rate limit using the GitHub API endpoint `/rate_limit`. This ensures that the bot does not exceed the allowed number of requests per hour. |
| 108 | +
|
| 109 | +### Fetch Repositories |
| 110 | +
|
| 111 | +The bot searches for repositories that were created in the last day and have less than 4 stars. This is done using the GitHub search API with a query parameter. |
| 112 | +
|
| 113 | +### Process Repositories |
| 114 | +
|
| 115 | +For each repository found, the bot: |
| 116 | +1. **Stars the Repository**: Stars the repository using the GitHub API if it hasn't been starred before. |
| 117 | +2. **Follows the User**: Follows the user who owns the repository if they haven't been followed before. |
| 118 | +
|
| 119 | +A delay of 5 seconds is introduced between each operation to avoid being flagged as spam. |
| 120 | +
|
| 121 | +### Undo Operations |
| 122 | +
|
| 123 | +The bot can undo its operations by un-starring repositories and unfollowing users. This is useful if you want to revert the actions performed by the bot. |
| 124 | +
|
| 125 | +### Graceful Shutdown |
| 126 | +
|
| 127 | +The bot listens for shutdown signals and stops its operations cleanly to ensure no incomplete actions are left. |
| 128 | +
|
| 129 | +## Contributing |
| 130 | +
|
| 131 | +If you would like to contribute to this project, please fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you would like to change. |
| 132 | +
|
| 133 | +## License |
| 134 | +
|
| 135 | +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details. |
| 136 | +
|
| 137 | +## Support |
| 138 | +
|
| 139 | +For support or any questions, please open an issue in the repository or contact me at [email protected]. |
0 commit comments