feat(bot): /start without a code on the demo stand opens a private copy of veteran Andrey
CI / ruff · pytest (pull_request) Successful in 2m45s
CI / ruff · pytest (pull_request) Successful in 2m45s
Refs #108 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -194,11 +194,28 @@ class TelegramChannel:
|
||||
await self._dispatch(chat_id, person.token, Event(type="start", params={"code": code}))
|
||||
return
|
||||
token = await self.directory.token_for(chat_id)
|
||||
if token is None and get_settings().demo_clock:
|
||||
token = await self._demo_copy(chat_id)
|
||||
if token is None:
|
||||
await self._say(chat_id, texts.not_connected)
|
||||
return
|
||||
await self._dispatch(chat_id, token, Event(type="start"))
|
||||
|
||||
async def _demo_copy(self, chat_id: int) -> str | None:
|
||||
"""Demo stand (DEMO_CLOCK): `/start` without a code gets a private copy of veteran Andrey (synthetic),
|
||||
starting from consent and the intake — the same entry as the ЕМИАС demo button of the web app."""
|
||||
from app.api.patient_web import _fresh_demo_copy
|
||||
|
||||
try:
|
||||
token = (await _fresh_demo_copy(start_in_chat=False)).token
|
||||
except Exception:
|
||||
log.exception("start: demo copy failed")
|
||||
return None
|
||||
if not await self.directory.bind(chat_id, token):
|
||||
return None
|
||||
log.info("start: demo copy bound tok=%s", _short(token))
|
||||
return token
|
||||
|
||||
async def on_text(self, chat_id: int, text: str | None) -> None:
|
||||
texts = load_texts()
|
||||
token = await self.directory.token_for(chat_id)
|
||||
|
||||
Reference in New Issue
Block a user