From f2681bd7adbcb482bd86bf862ab956cfa81b96db Mon Sep 17 00:00:00 2001 From: Sergey Date: Sun, 4 Oct 2020 23:28:07 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D0=BC=D0=B8=D0=B3?= =?UTF-8?q?=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20=D1=87=D0=B0=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- telegram.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/telegram.py b/telegram.py index 9f598d3..6e2d818 100644 --- a/telegram.py +++ b/telegram.py @@ -928,9 +928,10 @@ async def handle_new_group(msg: types.Message): await handle_join(msg) -@dp.message_handler(func=lambda msg: msg.migrate_to_chat_id is not None) +@dp.message_handler(content_types=types.ContentType.ANY, func=lambda message: message.migrate_to_chat_id) async def handle_chat_migration(msg: types.Message): - forwards = Forward.objects.filter(tgchat__cid=msg.migrate_from_chat_id) + # Юзеру сначала нужно выбрать чат для привязки, а уже ПОТОМ делать миграцию. Иначе старый chatid останется на иналйнкнопках + forwards = Forward.objects.filter(tgchat__cid=msg.chat.id) for forward in forwards: forward.tgchat.cid = msg.migrate_to_chat_id forward.tgchat.save()