From b38834b265a0409b08ce63c817bbbd564ea7eed5 Mon Sep 17 00:00:00 2001 From: mihalin Date: Wed, 15 Dec 2021 00:14:49 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B8=20=D1=81=D0=BE=D0=B7=D0=B4?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B8=20=D0=B3=D1=80=D1=83=D0=BF=D0=BF=D0=BE?= =?UTF-8?q?=D0=B2=D0=BE=D0=B3=D0=BE=20=D1=87=D0=B0=D1=82=D0=B0=20=D0=BE?= =?UTF-8?q?=D0=BD=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F=D0=B5=D1=82?= =?UTF-8?q?=D1=81=D1=8F=20=D0=B2=20=D1=81=D0=BF=D0=B8=D1=81=D0=BE=D0=BA=20?= =?UTF-8?q?olgram?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/custom.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server/custom.py b/server/custom.py index 6517099..a0b12fb 100644 --- a/server/custom.py +++ b/server/custom.py @@ -89,6 +89,18 @@ async def receive_invite(message: types.Message): break +async def receive_group_create(message: types.Message): + bot = db_bot_instance.get() + + chat, _ = await GroupChat.get_or_create(chat_id=message.chat.id, + defaults={"name": message.chat.full_name}) + chat.name = message.chat.full_name + await chat.save() + if chat not in await bot.group_chats.all(): + await bot.group_chats.add(chat) + await bot.save() + + async def receive_left(message: types.Message): bot = db_bot_instance.get() if message.left_chat_member.id == message.bot.id: @@ -139,6 +151,7 @@ class CustomRequestHandler(WebhookRequestHandler): 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]) + dp.register_message_handler(receive_group_create, content_types=[types.ContentType.GROUP_CHAT_CREATED]) return dp