Final release: Multi-session comment bot with filtering
Features: - Multi-account support (session files) - AI comments via Ollama - Telegram bot moderation - Filter by sessions and groups - Docker support - Auto-join groups - Log notifications - DB migration script Bug fixes: - Fixed comment_to for proper post targeting - Fixed entity lookup with multiple ID formats - Fixed callback handlers for filtering - Added auto-join before entity lookup
This commit is contained in:
42
bot/db.py
42
bot/db.py
@@ -264,6 +264,48 @@ def get_pending_comments() -> list:
|
||||
conn.close()
|
||||
|
||||
|
||||
def get_pending_comments_by_session(session_file: str) -> list:
|
||||
"""Получение ожидающих комментариев для конкретной сессии"""
|
||||
try:
|
||||
conn = get_connection()
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute('''
|
||||
SELECT * FROM comments
|
||||
WHERE status = 'pending' AND session_file = ?
|
||||
ORDER BY created_at DESC
|
||||
''', (session_file,))
|
||||
|
||||
return [dict(row) for row in cursor.fetchall()]
|
||||
except Exception as e:
|
||||
logger.error(f"Ошибка при получении ожидающих комментариев для сессии: {e}")
|
||||
return []
|
||||
finally:
|
||||
if 'conn' in locals():
|
||||
conn.close()
|
||||
|
||||
|
||||
def get_pending_comments_by_group(group_id: str) -> list:
|
||||
"""Получение ожидающих комментариев для конкретной группы"""
|
||||
try:
|
||||
conn = get_connection()
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute('''
|
||||
SELECT * FROM comments
|
||||
WHERE status = 'pending' AND chat_id = ?
|
||||
ORDER BY created_at DESC
|
||||
''', (group_id,))
|
||||
|
||||
return [dict(row) for row in cursor.fetchall()]
|
||||
except Exception as e:
|
||||
logger.error(f"Ошибка при получении ожидающих комментариев для группы: {e}")
|
||||
return []
|
||||
finally:
|
||||
if 'conn' in locals():
|
||||
conn.close()
|
||||
|
||||
|
||||
# === Сессии ===
|
||||
|
||||
def save_session(session_file: str, user_info: dict) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user