Message Guardian Bot is a Telegram bot designed to manage messages in groups, including saving messages, tracking changes, and restoring deleted messages. The bot is built using the Telethon framework for handling Telegram updates and SQLAlchemy for database interactions.
- Clone this repository:
git clone git@github.com/JM1k1/MessageGuardianBot.git
- Cd into MessageGuardianBot:
cd MessageGuardianBot
- Install Python 3.11+
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3 -y
sudo apt install python3-pip -y
- Install Poetry:
curl -sSL https://install.python-poetry.org | python3 -
- Install all dependencies:
poetry install
- Configure your environment variables. Create a .env file in the root directory of the project and add the following:
TELEGRAM_TOKEN=YOUR_TOKEN
FORWARD_CHAT_ID=YOUR_FORWARD_CHAT_ID
DATABASE_ENGINE=sqlite+aiosqlite:///database.db
- Initialize the database:
poetry run alembic upgrade head
- Run the bot:
poetry run python /src/application.py
- application.py: Main entry point for running the bot.
- client.py: Configures and starts the Telethon client.
- handlers.py: Handlers for processing different types of messages.
- logs/: Directory containing logs.
- logger.py: Configures logging for the application.
- settings.py: Contains configuration settings, including the bot token.
- crud.py: Contains CRUD operations for interacting with the database.
- database.py: Database setup and session management.
- models.py: SQLAlchemy models for the database schema.
- env.py: Alembic environment configuration file.
- script.py.mako: Template for new migration scripts.
- versions/: Directory containing migration scripts.
This project is licensed under the MIT License. See the LICENSE file for details.
For anyone who is interested in contributing to MessageGuardianBot, please make sure you fork the project and make a pull request.
