mirror of
https://github.com/civsocit/olgram.git
synced 2023-07-22 01:29:12 +03:00
миграция ID чата (fix #7)
This commit is contained in:
parent
ba0c2752a1
commit
645357995b
@ -3,7 +3,7 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: kartoza/postgis
|
image: postgres:13.4
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_USER=test_user
|
- POSTGRES_USER=test_user
|
||||||
- POSTGRES_PASSWORD=test_passwd
|
- POSTGRES_PASSWORD=test_passwd
|
||||||
|
@ -101,6 +101,17 @@ async def receive_left(message: types.Message):
|
|||||||
await bot.save()
|
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):
|
class CustomRequestHandler(WebhookRequestHandler):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -127,6 +138,7 @@ class CustomRequestHandler(WebhookRequestHandler):
|
|||||||
types.ContentType.VOICE])
|
types.ContentType.VOICE])
|
||||||
dp.register_message_handler(receive_invite, content_types=[types.ContentType.NEW_CHAT_MEMBERS])
|
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_left, content_types=[types.ContentType.LEFT_CHAT_MEMBER])
|
||||||
|
dp.register_message_handler(receive_migrate, content_types=[types.ContentType.MIGRATE_TO_CHAT_ID])
|
||||||
|
|
||||||
return dp
|
return dp
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user