From 63d059ddb040bb6e422ed5cc0aa9f8de1220848a Mon Sep 17 00:00:00 2001 From: Admin Date: Sun, 5 Apr 2026 22:09:05 +0400 Subject: [PATCH] =?UTF-8?q?=E2=8F=B0=20fix:=20timezone=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D0=B2=D0=B5=D1=80=D1=82=D0=B0=D1=86=D0=B8=D1=8F=20+=20ge?= =?UTF-8?q?neral=20topic=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Timezone: конвертация в UTC вместо простого удаления tzinfo - General topic: не добавлять message_thread_id для topic_id=1 - Telegram API требует БЕЗ message_thread_id для общего чата - Тест: пост 3 успешно опубликован - Исправлены 2 критические ошибки планировщика Co-authored-by: Qwen-Coder --- services/scheduler.py | 6 ++++-- web/app.py | 12 +++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/services/scheduler.py b/services/scheduler.py index 65b09c0..7c89943 100644 --- a/services/scheduler.py +++ b/services/scheduler.py @@ -344,7 +344,8 @@ class Scheduler: 'caption': post.text, 'parse_mode': 'HTML' } - if post.topic_id: + # Не добавляем message_thread_id для general (1) — это общий чат + if post.topic_id and post.topic_id > 1: params['message_thread_id'] = post.topic_id async with aiohttp.ClientSession(connector=connector) as http_session: @@ -363,7 +364,8 @@ class Scheduler: 'text': post.text, 'parse_mode': 'HTML' } - if post.topic_id: + # Не добавляем message_thread_id для general (1) — это общий чат + if post.topic_id and post.topic_id > 1: params['message_thread_id'] = post.topic_id async with aiohttp.ClientSession(connector=connector) as http_session: diff --git a/web/app.py b/web/app.py index 538a162..699fe06 100644 --- a/web/app.py +++ b/web/app.py @@ -888,12 +888,14 @@ async def api_create_scheduled_post( try: # Парсим время scheduled_dt = datetime.fromisoformat(scheduled_time) - - # Убираем timezone если есть + + # Если есть timezone - конвертируем в UTC if scheduled_dt.tzinfo is not None: - scheduled_dt = scheduled_dt.replace(tzinfo=None) - - # Проверяем что время в будущем + from datetime import timezone as tz + scheduled_dt = scheduled_dt.astimezone(tz.utc).replace(tzinfo=None) + logger.info(f"⏰ Время конвертирована в UTC: {scheduled_dt}") + + # Проверяем что время в будущем (по UTC) if scheduled_dt < datetime.utcnow(): return JSONResponse({ "success": False,