v1.8.0: YandexGPT-only NLP, unknown questions system, callback dedup, consent flow fixes, DELETE cascade, UTC+3, auto-detect sidebar menu, tel:/mailto: links
This commit is contained in:
+11
-1
@@ -13,6 +13,7 @@ class MaxAPI:
|
||||
self.base_url = settings.max_api_base
|
||||
self.token = settings.max_token
|
||||
self.client = httpx.AsyncClient(timeout=30.0)
|
||||
self.mock_replies: list = []
|
||||
|
||||
def _headers(self) -> dict:
|
||||
return {
|
||||
@@ -65,7 +66,8 @@ class MaxAPI:
|
||||
) -> dict:
|
||||
if user_id >= TEST_USER_THRESHOLD:
|
||||
logger.info(f"MOCK send_message to test user {user_id}: {text[:50]}")
|
||||
return {"ok": True, "mock": True}
|
||||
self.mock_replies.append(text)
|
||||
return {"ok": True, "mock": True, "text": text}
|
||||
payload = {"text": text, "notify": notify}
|
||||
if attachments:
|
||||
payload["attachments"] = attachments
|
||||
@@ -98,6 +100,14 @@ class MaxAPI:
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
|
||||
def pop_mock_replies(self) -> list:
|
||||
replies = list(self.mock_replies)
|
||||
self.mock_replies.clear()
|
||||
return replies
|
||||
|
||||
def is_test_user(self, user_id: int) -> bool:
|
||||
return user_id >= TEST_USER_THRESHOLD
|
||||
|
||||
async def close(self):
|
||||
await self.client.aclose()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user