An open API service indexing awesome lists of open source software.

https://github.com/lleballex/aiogram-template

Template of aiogram telegram bot
https://github.com/lleballex/aiogram-template

aiogram aiogram-bot-template aiogram3 python python-i18n telegram-bot template

Last synced: 24 days ago
JSON representation

Template of aiogram telegram bot

Awesome Lists containing this project

README

        

# โšก Aiogram bot template

It is a template you can use for creating telegram bot with aiogram 3. It supports internationalization

### Tools:

- ๐Ÿ’ช Aiogram (v3)
- ๐Ÿ˜„ i18n
- ๐Ÿคน๐Ÿฝ Loguru

## ๐Ÿ”ฅ Getting started

### Requirements:

- Python
- Make

### Installing

###### For linux

```bash
git clone [email protected]:lleballex/aiogram-template.git
cd aiogram-template
python3 -m venv env
. env/bin/activate
pip install -r requirements.txt
```

###### For windows

```bash
git clone [email protected]:lleballex/aiogram-template.git
cd aiogram-template
python -m venv env
env\scripts\activate
pip install -r requirements.txt
```

### Starting

```bash
python src/bot.py
```

## โœ Adding handlers

Just create new file in *src/handlers* folder or its subfolder

#### Initialize router and use it to handle events:

```python
from aiogram import Router
my_router = Router()
```

#### Add created router to router list in *src/handlers/\_\_init\_\_.py*:

```python
from .my_file import my_router
routers = [my_router]
```

## ๐Ÿ“– Internationalization

This template uses i18n. So wrap your messages in `aiogram.utils.i18n.gettext` to make it translatable\
More information you can find [here](https://docs.aiogram.dev/en/dev-3.x/utils/i18n.html#step-3-translate-texts)

#### Extracting messages (creating .pot):

```bash
make i18n-extract
```

#### Initializing a new language:

```
mkdir locales
pybabel init -i locales/messages.pot -d locales -D messages -l en
```

#### Compiling translations (.po -> .mo):

```bash
make i18n-compile
```

#### Updating translated messages (.po) with new extracted messages (.pot):

```bash
make i18n-update
```

## ๐Ÿ™‹๐Ÿฝโ€โ™‚๏ธ Contact me

[](https://t.me/lleballex)
[](https://vk.com/lleballex)