Skip to content

haxgun/telegram-bot-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

✨ Telegram Bot Template

uv GitHub License Stars Forks Issues

🚀 Technology Stack and Features

  • 🔧 Aiogram (v3.17) for building Telegram bots with ease.
  • 🪴 Fluentogram a proper way to use an i18n mechanism with Aiogram3.
  • 📊 SQLite for lightweight database storage using aiosqlite.
  • 🔌 Alembic for database migrations.
  • Asyncio for asynchronous programming.
  • 🛠️ Pydantic and Pydantic Settings for robust data validation and settings management.
  • 🔮 SQLAlchemy for database ORM.
  • 🎨 Loguru for advanced logging capabilities.
  • UV extremely fast Python package and project manager, written in Rust.

🛠️ Installation and Setup

📋 Prerequisites

  • Recommended Python version: 3.12
  • Make sure to have UV installed

🔧 Steps to Run

  1. Clone the repository:

    git clone https://github.com/haxgun/telegram-bot-template.git
    cd telegram-bot-template
  2. Install dependencies:

    uv init
  3. Set up the virtual environment:

    • Create a virtual environment: uv venv
    • Activate the virtual environment: source ./venv/bin/activate
  4. Set up the environment variables:

    • Create a .env file in the project root.
    • Add the necessary configurations (e.g., BOT_TOKEN, ADMIN_IDS).
  5. Run database migrations:

    alembic revision --autogenerate -m "Initial revision"
    alembic upgrade head
  6. Start the bot:

    python3 -m bot.main

🗂️ Directory Structure

telegram-bot-template/
├── bot/
│   ├── __init__.py
│   ├── main.py             # Main entry point
│   ├── config.py           # Configuration settings
│   ├── handlers/           # Bot handlers ✋
│   ├── keyboards/          # Custom keyboards 🎹
│   ├── i18n/               # Internationalization 🌍
│   ├── middlewares/        # Custom middlewares 🔑
│   ├── services/           # Utility services 🔧
│   ├── migrations/         # Alembic migrations 🔄
│   │   ├── env.py          # Environment variables 🌱
│   │   ├── script.py.mako  # Alembic migration script 🔨
│   ├── database/           # Database files 📊
│   │   ├── database.py     # Database setup 🗄️
│   │   ├── models.py       # Database models 🧑‍💻
├── data/                   # Data files 📂
│   ├── __init__.py
├── .env.example            # Example environment variables 🌱
├── .gitignore              # Ignored files 🚫
├── alembic.ini             # Configuration file for Alembic ⚙️
├── LICENSE                 # License file 📜
├── pyproject.toml          # Dependencies 📋
├── requirements.txt        # Dependencies 🔌
└── README.md               # Project documentation 📚

✨ Key Features

  • Modular architecture for scalability.
  • Asynchronous database operations with SQLite.
  • Easy-to-use logging via Loguru.
  • Seamless environment variable management with Pydantic Settings.
  • Effortless database migrations with Alembic.

🌱 Environment Variables

Ensure you have the following variables set in your .env file:

BOT_TOKEN=your-telegram-bot-token
ADMIN_IDS=[AdminID1, AdminID2, AdminID3]

🧑‍💻 Contributing

  1. Fork the repository.
  2. Create your feature branch:
    git checkout -b feature-name
  3. Commit your changes:
    git commit -m "Add feature"
  4. Push to the branch:
    git push origin feature-name
  5. Open a pull request.

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.


🎉 Happy Coding! 🌟

About

✨ Telegram bot template with AIOgram 3.17

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published