From 645357995b1d960821861a129200c8d729a0d060 Mon Sep 17 00:00:00 2001 From: mihalin Date: Tue, 14 Dec 2021 23:55:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BC=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=20ID=20=D1=87=D0=B0=D1=82=D0=B0=20(fix=20#7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose-debug.yaml | 2 +- server/custom.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docker-compose-debug.yaml b/docker-compose-debug.yaml index ada6e48..16e5cad 100644 --- a/docker-compose-debug.yaml +++ b/docker-compose-debug.yaml @@ -3,7 +3,7 @@ version: '3' services: postgres: - image: kartoza/postgis + image: postgres:13.4 environment: - POSTGRES_USER=test_user - POSTGRES_PASSWORD=test_passwd diff --git a/server/custom.py b/server/custom.py index 170048f..6517099 100644 --- a/server/custom.py +++ b/server/custom.py @@ -101,6 +101,17 @@ async def receive_left(message: types.Message): await bot.save() +async def receive_migrate(message: types.Message): + bot = db_bot_instance.get() + from_id = message.chat.id + to_id = message.migrate_to_chat_id + + chats = await bot.group_chats.filter(chat_id=from_id) + for chat in chats: + chat.chat_id = to_id + await chat.save(update_fields=["chat_id"]) + + class CustomRequestHandler(WebhookRequestHandler): def __init__(self, *args, **kwargs): @@ -127,6 +138,7 @@ class CustomRequestHandler(WebhookRequestHandler): types.ContentType.VOICE]) dp.register_message_handler(receive_invite, content_types=[types.ContentType.NEW_CHAT_MEMBERS]) dp.register_message_handler(receive_left, content_types=[types.ContentType.LEFT_CHAT_MEMBER]) + dp.register_message_handler(receive_migrate, content_types=[types.ContentType.MIGRATE_TO_CHAT_ID]) return dp