From 6004f9d9af2abaab1f14dbaec1bf2287fccafcf2 Mon Sep 17 00:00:00 2001 From: mihalin Date: Sat, 19 Feb 2022 05:38:03 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B5=20=D1=83=D0=B2=D0=B5=D0=BB=D0=B8?= =?UTF-8?q?=D1=87=D0=B8=D0=B2=D0=B0=D1=82=D1=8C=20incoming=20messages=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D1=8B=D1=85=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=D1=85=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B1=D0=B5=D0=BA=D0=B5=D0=BD=D0=B4=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/custom.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/custom.py b/server/custom.py index adb7d7d..9270553 100644 --- a/server/custom.py +++ b/server/custom.py @@ -56,9 +56,6 @@ async def message_handler(message: types.Message, *args, **kwargs): return SendMessage(chat_id=message.chat.id, text="Вы заблокированы в этом боте") - bot.incoming_messages_count = F("incoming_messages_count") + 1 - await bot.save(update_fields=["incoming_messages_count"]) - # Пересылаем сообщение в супер-чат if is_super_group: thread_first_message = await _redis.get(_thread_uniqie_id(bot.pk, message.chat.id)) @@ -81,6 +78,9 @@ async def message_handler(message: types.Message, *args, **kwargs): await _redis.set(_message_unique_id(bot.pk, new_message.message_id), message.chat.id, pexpire=ServerSettings.redis_timeout_ms()) + bot.incoming_messages_count = F("incoming_messages_count") + 1 + await bot.save(update_fields=["incoming_messages_count"]) + # И отправить пользователю специальный текст, если он указан if bot.second_text: return SendMessage(chat_id=message.chat.id, text=bot.second_text) @@ -121,6 +121,7 @@ async def message_handler(message: types.Message, *args, **kwargs): bot.outgoing_messages_count = F("outgoing_messages_count") + 1 await bot.save(update_fields=["outgoing_messages_count"]) + elif super_chat_id > 0: # в супер-чате кто-то пишет сообщение сам себе, только для личных сообщений await message.forward(super_chat_id)