Stats Bot is a Python-based Telegram bot that generates statistics about your group chat. It can provide insights such as the top 10 users by number of messages and average message length.
- User Statistics: The bot can generate a table of the top 10 users by the number of messages and average message length.
- Group Statistics: The bot can provide insights about the group such as the total number of messages, active users, etc. [WIP]
- Data Visualization: The bot can plot a bar chart to visualize the data it generates.
To get started, add the bot to your group and send the /textstats
command. The bot will then generate the statistics and send a message with the results.
This project uses Python 3.8+ and relies on several packages for its functionality. To set up a development environment, follow these steps:
- Clone the repository
- Create a virtual environment:
python3 -m venv venv
- Activate the virtual environment:
source venv/bin/activate
(Linux/Mac) orvenv\Scripts\activate
(Windows) - Install the dependencies:
pip install -r requirements.txt
- Run the bot:
python -m stats_bot
The bot uses a configuration file (config.ini
) to store sensitive information such as the bot token. Make sure to create this file and add your bot token like so:
[stats_bot]
token = YOUR_BOT_TOKEN
To run the bot as a systemd service, create a file called statsbot.service
in /etc/systemd/system
and add the following:
[Unit]
Description=Stats Bot Service
After=network.target
[Service]
User=ubuntu
WorkingDirectory=/home/ubuntu/stats-bot
ExecStartPre=/usr/bin/python3 -m venv venv
ExecStartPre=/home/ubuntu/stats-bot/venv/bin/pip install -r requirements.txt
ExecStart=/home/ubuntu/stats-bot/venv/bin/python -m stats_bot
Restart=always
[Install]
WantedBy=multi-user.target
Do not forget to change the User
and WorkingDirectory
fields to match your environment.
Then, run the following commands to enable and start the service:
sudo systemctl enable statsbot.service
sudo systemctl start statsbot.service
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the terms of the MIT license.