This project is a Flask-based web application designed to monitor the following counts of specified usernames on a social media platform. It sends notifications to a Telegram chat whenever there is an increase in the number of accounts a user is following.
- Set Usernames: Specify a list of usernames to monitor.
- Start/Stop Monitoring: Start or stop the monitoring process.
- Following Count Checking: Periodically checks following counts and detects new followings.
- Telegram Notifications: Sends a message to a specified Telegram chat when new followings are detected.
- Flask: Web framework for building the application.
- APScheduler: For scheduling periodic following count checks.
- Telegram Bot API: For sending notifications.
- Decouple: For managing configuration variables.
-
Clone the repository:
git clone https://github.com/maron09/following-monitoring-bot.git cd following-monitoring-bot
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the dependencies:
pip install -r requirements.txt
-
Create a
.env
file in the project root and add your Telegram bot token and chat ID:TELEGRAM_BOT_TOKEN=your-telegram-bot-token TELEGRAM_CHAT_ID=your-telegram-chat-id
-
Ensure you have the
following
module with aget_following_count
function:# following.py def get_following_count(username): # Implement this function to return the following count for the given username pass
-
Run the Flask application:
python app.py
-
Open your web browser and navigate to:
http://127.0.0.1:5000/
GET /
: Renders the index page.POST /set_usernames
: Sets the list of usernames to monitor. Expects a JSON payload with ausernames
key.{ "usernames": ["username1", "username2"] }
POST /start_monitoring
: Starts the monitoring process.POST /stop_monitoring
: Stops the monitoring process.
-
Set Usernames:
- Use the
/set_usernames
endpoint to specify the usernames you want to monitor. - This initializes the
last_follower_counts
dictionary with the current following counts for the provided usernames.
- Use the
-
Start Monitoring:
- Use the
/start_monitoring
endpoint to start the periodic following count checks. - The
check_followers
function is scheduled to run every minute.
- Use the
-
Check Followers:
- The
check_followers
function retrieves the current following count for each username. - If there is an increase in the following count, a Telegram message is sent to the specified chat.
- The
-
Stop Monitoring:
- Use the
/stop_monitoring
endpoint to stop the monitoring process.
- Use the
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please fork the repository and submit a pull request.
For any inquiries, please reach out to [chimarokeonyebi@gmail.com].