Skip to content

Commit 81aadf9

Browse files
committed
feat: dropped support for Python 3.8 and add Python 3.13
1 parent 85da324 commit 81aadf9

24 files changed

+561
-476
lines changed

.github/workflows/python-app.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-22.04
88
strategy:
99
matrix:
10-
python-version: ["3.9", "3.10", "3.11", "3.12"]
10+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
1111

1212
steps:
1313
- name: Setup dependencies
@@ -20,7 +20,7 @@ jobs:
2020
env:
2121
BOT_CREDENTIALS: ${{ secrets.END_TO_END_TESTS_BOT_CREDENTIALS }}
2222
run: |
23-
poetry run ./scripts/test --cov-report=xml
23+
poetry run ./scripts/test --cov=pybotx --cov-report=xml
2424
2525
- name: Upload coverage to Codecov
2626
uses: codecov/codecov-action@v2

README.md

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
[![Coverage](https://codecov.io/gh/ExpressApp/pybotx/branch/master/graph/badge.svg)](https://codecov.io/gh/ExpressApp/pybotx/branch/master)
88
[![Code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
99

10+
1011
## Особенности
1112

1213
* Простая для использования
@@ -15,6 +16,7 @@
1516
* Полное покрытие тестами
1617
* Полное покрытие аннотациями типов
1718

19+
1820
## Установка
1921

2022
Используя `poetry`:
@@ -26,14 +28,15 @@ poetry add pybotx
2628
**Предупреждение:** Данный проект находится в активной разработке (`0.y.z`) и
2729
его API может быть изменён при повышении минорной версии.
2830

31+
2932
## Информация о мессенджере eXpress и платформе BotX
3033

31-
[Документация](https://docs.express.ms/) по мессенджеру (включая руководство пользователя и администратора).
34+
Документацию по мессенджеру (включая руководство пользователя и администратора)
35+
можно найти на [официальном сайте](https://express.ms/).
3236

3337
Перед тем, как продолжать знакомство с библиотекой `pybotx`,
34-
советуем прочитать данные
35-
статьи: Что
36-
такое [чат-боты](https://docs.express.ms/chatbots/developer-guide/#%D1%87%D0%B0%D1%82-%D0%B1%D0%BE%D1%82-%D0%B8-smartapp)
38+
советуем прочитать данные статьи: Что такое [чат-боты]
39+
(https://docs.express.ms/chatbots/developer-guide/#%D1%87%D0%B0%D1%82-%D0%B1%D0%BE%D1%82-%D0%B8-smartapp)
3740
и [SmartApp](https://docs.express.ms/smartapps/developer-guide/)
3841
и [Взаимодействие с Bot API и BotX API](https://docs.express.ms/chatbots/developer-guide/api/).
3942
В этих статьях находятся исчерпывающие примеры работы с платформой, которые
@@ -42,6 +45,7 @@ poetry add pybotx
4245
Также не будет лишним ознакомиться с [документацией по плаформе BotX
4346
](https://hackmd.ccsteam.ru/s/botx_platform).
4447

48+
4549
## Примеры готовых проектов на базе pybotx
4650

4751
* [Next Feature Bot](https://github.com/ExpressApp/next-feature-bot) - бот,
@@ -51,6 +55,7 @@ poetry add pybotx
5155
* [Weather SmartApp](https://github.com/ExpressApp/weather-smartapp) -
5256
приложение для просмотра погоды.
5357

58+
5459
## Минимальный пример бота (интеграция с FastAPI)
5560

5661
```python
@@ -145,11 +150,11 @@ async def callback_handler(request: Request) -> JSONResponse:
145150

146151
## Примеры
147152

153+
148154
### Получение сообщений
149155

150156
*([подробное описание функции](
151157
https://docs.express.ms/chatbots/developer-guide/api/bot-api/command/))*
152-
153158
```python
154159
from uuid import UUID
155160

@@ -192,11 +197,11 @@ async def default_handler(_: IncomingMessage, bot: Bot) -> None:
192197
print("Hello from default handler")
193198
```
194199

200+
195201
### Получение системных событий
196202

197203
*([подробное описание функции](
198204
https://docs.express.ms/chatbots/developer-guide/api/bot-api/command/#%D1%81%D0%B8%D1%81%D1%82%D0%B5%D0%BC%D0%BD%D1%8B%D0%B5-%D0%BA%D0%BE%D0%BC%D0%B0%D0%BD%D0%B4%D1%8B))*
199-
200205
```python
201206
from pybotx import *
202207

@@ -215,6 +220,7 @@ async def smartapp_event_handler(event: SmartAppEvent, bot: Bot) -> None:
215220
print(f"Got `smartapp_event` event: {event}")
216221
```
217222

223+
218224
### Получение синхронных SmartApp событий
219225

220226
```python
@@ -226,7 +232,7 @@ collector = HandlerCollector()
226232
# Обработчик синхронных Smartapp событий, приходящих на эндпоинт `/smartapps/request`
227233
@collector.sync_smartapp_event
228234
async def handle_sync_smartapp_event(
229-
event: SmartAppEvent, bot: Bot,
235+
event: SmartAppEvent, bot: Bot,
230236
) -> BotAPISyncSmartAppEventResultResponse:
231237
print(f"Got sync smartapp event: {event}")
232238
return BotAPISyncSmartAppEventResultResponse.from_domain(
@@ -235,6 +241,7 @@ async def handle_sync_smartapp_event(
235241
)
236242
```
237243

244+
238245
### Middlewares
239246

240247
*(Этот функционал относится исключительно к `pybotx`)*
@@ -248,9 +255,9 @@ collector = HandlerCollector()
248255

249256

250257
async def custom_api_client_middleware(
251-
message: IncomingMessage,
252-
bot: Bot,
253-
call_next: IncomingMessageHandlerFunc,
258+
message: IncomingMessage,
259+
bot: Bot,
260+
call_next: IncomingMessageHandlerFunc,
254261
) -> None:
255262
# До вызова `call_next` (обязателен в каждой миддлвари) располагается
256263
# код, который выполняется до того, как сообщение дойдёт до
@@ -292,18 +299,18 @@ ADMIN_HUIDS = (UUID("123e4567-e89b-12d3-a456-426614174000"),)
292299

293300

294301
async def request_id_middleware(
295-
message: IncomingMessage,
296-
bot: Bot,
297-
call_next: IncomingMessageHandlerFunc,
302+
message: IncomingMessage,
303+
bot: Bot,
304+
call_next: IncomingMessageHandlerFunc,
298305
) -> None:
299306
message.state.request_id = uuid4()
300307
await call_next(message, bot)
301308

302309

303310
async def ensure_admin_middleware(
304-
message: IncomingMessage,
305-
bot: Bot,
306-
call_next: IncomingMessageHandlerFunc,
311+
message: IncomingMessage,
312+
bot: Bot,
313+
call_next: IncomingMessageHandlerFunc,
307314
) -> None:
308315
if message.sender.huid not in ADMIN_HUIDS:
309316
await bot.answer_message("You are not admin")
@@ -327,11 +334,11 @@ admin_collector = HandlerCollector(middlewares=[ensure_admin_middleware])
327334
main_collector.include(admin_collector)
328335
```
329336

337+
330338
### Отправка сообщения
331339

332340
*([подробное описание функции](
333341
https://docs.express.ms/chatbots/developer-guide/development-and-debugging/examples/#%D0%BE%D1%82%D0%BF%D1%80%D0%B0%D0%B2%D0%BA%D0%B0-%D1%81%D0%BE%D0%BE%D0%B1%D1%89%D0%B5%D0%BD%D0%B8%D1%8F))*
334-
335342
```python
336343
from uuid import UUID
337344

@@ -382,11 +389,11 @@ async def prebuild_answer_handler(message: IncomingMessage, bot: Bot) -> None:
382389
await bot.send(message=answer)
383390
```
384391

392+
385393
#### Отправка сообщения с кнопками
386394

387395
*([подробное описание функции](
388396
https://docs.express.ms/chatbots/developer-guide/development-and-debugging/examples/#%D0%BE%D1%82%D0%BF%D1%80%D0%B0%D0%B2%D0%BA%D0%B0-%D1%81%D0%BE%D0%BE%D0%B1%D1%89%D0%B5%D0%BD%D0%B8%D1%8F-%D1%81-%D0%BA%D0%BD%D0%BE%D0%BF%D0%BA%D0%B0%D0%BC%D0%B8))*
389-
390397
```python
391398
from pybotx import *
392399

@@ -428,11 +435,11 @@ async def bubbles_handler(message: IncomingMessage, bot: Bot) -> None:
428435
)
429436
```
430437

438+
431439
#### Упоминание пользователя
432440

433441
*([подробное описание функции](
434442
https://docs.express.ms/chatbots/developer-guide/development-and-debugging/examples/#%D1%83%D0%BF%D0%BE%D0%BC%D0%B8%D0%BD%D0%B0%D0%BD%D0%B8%D0%B5-%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D0%B5%D0%BB%D1%8F))*
435-
436443
```python
437444
from pybotx import *
438445

@@ -455,11 +462,11 @@ async def echo_contact_handler(message: IncomingMessage, bot: Bot) -> None:
455462
await bot.answer_message(answer)
456463
```
457464

465+
458466
#### Отправка файла в сообщении
459467

460468
*([подробное описание функции](
461469
https://docs.express.ms/chatbots/developer-guide/development-and-debugging/examples/#%D0%BE%D1%82%D0%BF%D1%80%D0%B0%D0%B2%D0%BA%D0%B0-%D1%84%D0%B0%D0%B9%D0%BB%D0%B0-%D0%B2-%D1%81%D0%BE%D0%BE%D0%B1%D1%89%D0%B5%D0%BD%D0%B8%D0%B8))*
462-
463470
```python
464471
from aiofiles.tempfile import NamedTemporaryFile
465472

@@ -494,7 +501,6 @@ async def echo_file_handler(message: IncomingMessage, bot: Bot) -> None:
494501

495502
*([подробное описание функции](
496503
https://docs.express.ms/chatbots/developer-guide/development-and-debugging/examples/#%D1%80%D0%B5%D0%B4%D0%B0%D0%BA%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5-%D1%81%D0%BE%D0%BE%D0%B1%D1%89%D0%B5%D0%BD%D0%B8%D0%B9))*
497-
498504
```python
499505
from pybotx import *
500506

@@ -533,7 +539,6 @@ async def increment_handler(message: IncomingMessage, bot: Bot) -> None:
533539

534540
*([подробное описание функции](
535541
https://hackmd.ccsteam.ru/s/E9MPeOxjP#%D0%A3%D0%B4%D0%B0%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5-%D1%81%D0%BE%D0%BE%D0%B1%D1%89%D0%B5%D0%BD%D0%B8%D1%8F))*
536-
537542
```python
538543
from pybotx import *
539544

@@ -558,6 +563,7 @@ async def deleted_message_handler(message: IncomingMessage, bot: Bot) -> None:
558563
await bot.answer_message("Self-deleted message", bubbles=bubbles)
559564
```
560565

566+
561567
### Обработчики ошибок
562568

563569
*(Этот функционал относится исключительно к `pybotx`)*
@@ -569,9 +575,9 @@ from pybotx import *
569575

570576

571577
async def internal_error_handler(
572-
message: IncomingMessage,
573-
bot: Bot,
574-
exc: Exception,
578+
message: IncomingMessage,
579+
bot: Bot,
580+
exc: Exception,
575581
) -> None:
576582
logger.exception("Internal error:")
577583

@@ -593,7 +599,6 @@ bot = Bot(
593599

594600
*([подробное описание функции](
595601
https://docs.express.ms/chatbots/developer-guide/development-and-debugging/examples/#%D1%81%D0%BE%D0%B7%D0%B4%D0%B0%D0%BD%D0%B8%D0%B5-%D1%87%D0%B0%D1%82%D0%B0))*
596-
597602
```python
598603
from pybotx import *
599604

@@ -625,7 +630,6 @@ async def create_group_chat_handler(message: IncomingMessage, bot: Bot) -> None:
625630

626631
*([подробное описание функции](
627632
https://docs.express.ms/chatbots/developer-guide/development-and-debugging/examples/#%D0%BF%D0%BE%D0%B8%D1%81%D0%BA-%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D0%B5%D0%BB%D1%8F))*
628-
629633
```python
630634
import dataclasses
631635

@@ -652,7 +656,6 @@ async def search_user_handler(message: IncomingMessage, bot: Bot) -> None:
652656

653657
*([подробное описание функции](
654658
https://docs.express.ms/chatbots/developer-guide/development-and-debugging/examples/#%D0%BF%D0%BE%D0%BB%D1%83%D1%87%D0%B5%D0%BD%D0%B8%D0%B5-%D1%81%D0%BF%D0%B8%D1%81%D0%BA%D0%B0-%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D0%B5%D0%BB%D0%B5%D0%B9-%D0%BD%D0%B0-cts))*
655-
656659
```python
657660
from pybotx import *
658661

@@ -662,11 +665,11 @@ collector = HandlerCollector()
662665
@collector.command("/get_users_list", description="Get a list of users")
663666
async def users_list_handler(message: IncomingMessage, bot: Bot) -> None:
664667
async with bot.users_as_csv(
665-
bot_id=message.bot.id,
666-
cts_user=True,
667-
unregistered=False,
668-
botx=False,
668+
bot_id=message.bot.id,
669+
cts_user=True,
670+
unregistered=False,
671+
botx=False,
669672
) as users:
670673
async for user in users:
671674
print(user)
672-
```
675+
```

0 commit comments

Comments
 (0)