72b6879f4b
- Refactored max_bot from nested packages to flat module structure - Q2: Extended BotUser model (patronymic, email, org, address, vcf_raw, contact_hash, phone_verified, email_verified, last_interaction, total_conversations, total_tickets) - Q2: VCF parser (FN, N, TEL, EMAIL, ORG, ADR), upsert on re-contact, NLP history context (_get_user_history_context -> YandexGPT) - Q1: Broadcast preview modal with 10s confirmation timer - Q3: CSS var(--white)->var(--bg-card), var(--text)->var(--text-primary) - Q4: bot_settings showNotification(), editable max_bot_id - Q5: Webhook secret passthrough via X-Max-Bot-Api-Secret - Masking sensitive keys, dialog_cleared handler, migrate via _add_column_if_not_exists() - Rate limit (asyncio.sleep 0.5 per 10), dead code removed, conv.intent context in contact.py - Portal pages: bot_consent, bot_kb (edit), bot_settings, bot_test, bot_tickets, portal_settings - Tests: 21/21 passing, added test_yandex_gpt.py, test_email_sender.py - Deploy: deploy_full.sh, schema.sql, seed_knowledge_base.sql
62 lines
1.8 KiB
Python
62 lines
1.8 KiB
Python
from __future__ import annotations
|
|
import re
|
|
import os
|
|
from typing import Optional, List, Tuple
|
|
from app.config import settings
|
|
|
|
|
|
class ConfigReader:
|
|
def __init__(self):
|
|
self._cache = {}
|
|
self._loaded = False
|
|
|
|
def load(self, path: Optional[str] = None) -> dict:
|
|
filepath = path or settings.config_php_path
|
|
if not os.path.isfile(filepath):
|
|
return self._fallback()
|
|
|
|
with open(filepath, "r", encoding="utf-8") as f:
|
|
content = f.read()
|
|
|
|
constants = {}
|
|
pattern = re.compile(r"define\(\s*'(\w+)'\s*,\s*'([^']*)'\s*\)")
|
|
for match in pattern.finditer(content):
|
|
constants[match.group(1)] = match.group(2)
|
|
|
|
self._cache = constants
|
|
self._loaded = True
|
|
return constants
|
|
|
|
def _fallback(self) -> dict:
|
|
self._cache = {
|
|
"PHONE_MAIN": "+7 (861) 203-33-30",
|
|
"PHONE_MAIN_LINK": "+78612033330",
|
|
"PHONE_SECOND": "+7 (995) 203-33-30",
|
|
"PHONE_SECOND_LINK": "+79952033330",
|
|
"SITE_MAIL": "mail@aegisone.ru",
|
|
"SITE_MAIL_FROM": "no-reply@aegisone.ru",
|
|
"SITE_MAIL_TO": "mail@aegisone.ru",
|
|
}
|
|
self._loaded = True
|
|
return self._cache
|
|
|
|
def get(self, key: str, default: str = "") -> str:
|
|
if not self._loaded:
|
|
self.load()
|
|
return self._cache.get(key, default)
|
|
|
|
def get_phones(self) -> List[Tuple[str, str]]:
|
|
return [
|
|
(self.get("PHONE_MAIN"), self.get("PHONE_MAIN_LINK")),
|
|
(self.get("PHONE_SECOND"), self.get("PHONE_SECOND_LINK")),
|
|
]
|
|
|
|
def get_site_mail(self) -> str:
|
|
return self.get("SITE_MAIL", "mail@aegisone.ru")
|
|
|
|
def get_mail_from(self) -> str:
|
|
return self.get("SITE_MAIL_FROM", "no-reply@aegisone.ru")
|
|
|
|
|
|
config_reader = ConfigReader()
|