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