From 0e46a1ca7f3e6a824557b11988edcac1e42ed24a Mon Sep 17 00:00:00 2001 From: Macbook Date: Sat, 3 Jan 2026 11:12:55 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B7=D0=B4=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=B8=D1=8F=20?= =?UTF-8?q?=D1=81=20=D0=94=D0=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.db | Bin 110592 -> 110592 bytes app.py | 20 ++++++++++++++++++++ vk_handler.py | 20 ++++++++++++-------- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/app.db b/app.db index 873a7ccd82011003c6eff8bce49b4ff0ffc3a953..e4c781c8a3c1350d14d754c28fa227ac63b43617 100644 GIT binary patch delta 216 zcmZp8z}E19ZGtqT_(U0JR&fTsHqDJGh4ZybJxwBWy;F@M(y9WZT>Si!D$T;G@>9}{ z5|br6c}6iedO1j9 zMP))nRb*0QbZSXXMKCmYZZ%M0GEuUi0Z<7HyZ{9N?f?jXvkLHa2n2{aVGxsp_~w^f zHvuoRg8J|Rlkcq+FElYSIW;mcGBqtRGA%MRATc&NGC4XkGA=nZIXE{p0003d010I| z86f}wf++w1laCQf3Nbl2I4v bool: return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) - # Основное условие: совпадение дня и месяца - conditions = [ + # условия ТОЛЬКО по дате + date_conditions = [ and_( func.strftime("%d", UsersBirthdate.birthdate) == day, func.strftime("%m", UsersBirthdate.birthdate) == month, ) ] - # Если 28 февраля и год НЕ високосный — добавляем родившихся 29.02 + # 29 февраля для невисокосного года if today.month == 2 and today.day == 28 and not is_leap_year(today.year): - conditions.append( + date_conditions.append( and_( func.strftime("%d", UsersBirthdate.birthdate) == "29", func.strftime("%m", UsersBirthdate.birthdate) == "02", ) ) - conditions.append(UsersBirthdate.enabled == True) - birthdayUsers = UsersBirthdate.query.filter(or_(*conditions)).all() + birthdayUsers = UsersBirthdate.query.filter( + UsersBirthdate.enabled.is_(True), + or_(*date_conditions), + ).all() if not birthdayUsers: - logger.info("Нет пользователей с днем рождения") + logger.info(f"Нет пользователей с днем рождения {day}.{month}") return + else: + logger.info(f"Найдено {len(birthdayUsers)} пользователей с днем рождения") vkApi = VkAPI.query.first() if not vkApi: @@ -95,7 +99,7 @@ def handle_vk_birthdate(): owner_id=-vkApi.group_id, from_group=1, message=user.congratulations.strip(), - attachments=user.photo_link, + attachments=user.photo_link.replace("https://vk.com/", ""), ) logger.info(f"Пост #{new_post.get('post_id')} создан")