45 lines
1.7 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from telegram import Update
from telegram.ext import CallbackContext
from utils.prefixes import PREFIXES
from utils.logger import logger
from utils.database import USER_DATA
def parse_names_helper(text):
words = text.split()
names = []
current_prefixes = []
logger.info(f"Check prefixes: {PREFIXES}")
for word in words:
# Если слово является префиксом, добавляем его в список текущих >
if word in PREFIXES:
current_prefixes.append(word)
# Если слово не префикс - это имя
else:
# Если есть накопленные префиксы - соединяем их с именем
if current_prefixes:
names.append(" ".join(current_prefixes + [word.replace(',','')]))
current_prefixes = []
else:
names.append(word.replace(',',''))
logger.info(f"Check helper: {names}")
return names
async def notify_admins(update: Update, context: CallbackContext):
bot = context.bot
admin_ids = get_admin_ids() # Функция получения ID админов
unread_count = get_unread_messages_count() # Функция получения количества непрочитанных
if unread_count > 0:
for admin_id in admin_ids:
try:
await bot.send_message(
chat_id=admin_id,
text=f"⚠️ У вас {unread_count} непрочитанных записок\n"
f"От {get_users_count()} пользователей"
)
except TelegramError as e:
logger.error(f"Ошибка отправки уведомления админу {admin_id}: {e}")