Merge pull request #128 from izzzzzi/main

Fix process_message_to_all
This commit is contained in:
Vladislav Lisitsyn
2025-01-06 19:20:45 +03:00
committed by GitHub
+6 -6
View File
@@ -34,7 +34,7 @@ async def handle_admin_callback_query(callback_query: CallbackQuery, state: FSMC
async def handle_admin_message(message: types.Message, state: FSMContext):
await state.clear()
BOT_VERSION = "3.2.4-beta" # Укажите текущую версию бота
BOT_VERSION = "3.2.5-beta" # Укажите текущую версию бота
builder = InlineKeyboardBuilder()
builder.row(
@@ -309,22 +309,22 @@ async def process_message_to_all(
send_to = state_data.get('send_to', 'all')
if send_to == 'all':
tg_ids = await session.fetch("SELECT DISTINCT c.tg_id FROM connections c")
tg_ids = await session.fetch("SELECT DISTINCT tg_id FROM connections")
elif send_to == 'subscribed':
tg_ids = await session.fetch("""
SELECT DISTINCT c.tg_id
FROM connections c
JOIN keys k ON c.tg_id = k.tg_id
WHERE k.expiry_time > CURRENT_TIMESTAMP
""")
WHERE k.expiry_time > $1
""", int(datetime.utcnow().timestamp() * 1000))
elif send_to == 'unsubscribed':
tg_ids = await session.fetch("""
SELECT c.tg_id
FROM connections c
LEFT JOIN keys k ON c.tg_id = k.tg_id
GROUP BY c.tg_id
HAVING COUNT(k.tg_id) = 0 OR MAX(k.expiry_time) <= CURRENT_TIMESTAMP
""")
HAVING COUNT(k.tg_id) = 0 OR MAX(k.expiry_time) <= $1
""", int(datetime.utcnow().timestamp() * 1000))
total_users = len(tg_ids)
success_count = 0