Skip to content

feat(api): telegram /start webhook with inline Mini App launch button - #56

Merged
temrjan merged 1 commit into
mainfrom
feat/bot-start-webhook
Jul 29, 2026
Merged

feat(api): telegram /start webhook with inline Mini App launch button#56
temrjan merged 1 commit into
mainfrom
feat/bot-start-webhook

Conversation

@temrjan

@temrjan temrjan commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Команды бота /start /lang /help были объявлены, но обработчика/вебхука не было — мертвы. Добавлен POST /telegram/webhook.

Что делает

/start /help /lang → трёхъязычный (ru/uz/en) welcome с inline web_app кнопкой «🥇 Открыть приложение» → app.oltinpay.com.

Безопасность (новый внешний вход на funds-api)

  • Секрет-гейт X-Telegram-Bot-Api-Secret-Token первым (constant-time hmac.compare_digest); тело парсится только после гейта.
  • Fail-closed: секрет не задан → 503. Неверный/нет заголовка → 403.
  • web_app URL — константа из конфига (нет SSRF/инъекции); ввод пользователя в HTML не подставляется.

Гейты

  • ruff ✅ · mypy (+src/telegram/) ✅ 0 ошибок · pytest 174 passed / 2 skipped
  • 11 тестов, red→green показан (11/11 падали без фичи).

Деплой (отдельно, вручную)

Секрет в .env сервера → rebuild api → setWebhook. + Капитан включает Main Mini App в BotFather для ?startapp.

The bot advertised /start /lang /help but had no handler or webhook, so the
commands were dead. Add POST /telegram/webhook: it validates the
X-Telegram-Bot-Api-Secret-Token header (constant-time, fails closed if the
secret is unset), then replies to /start /help /lang with a trilingual
(ru/uz/en) welcome carrying an inline web_app button that opens the Mini App.

- src/telegram/{schemas,messages,router}.py + registration in main.py
- send_telegram_notification gains an optional reply_markup (backward compatible)
- config: telegram_webhook_secret + telegram_webapp_url
- 11 tests (red->green shown): secret gate, fail-closed, command parsing,
  language selection, non-command ignored
- mypy CI extended to src/telegram/; RUF001 per-file-ignore for Cyrillic copy
@temrjan
temrjan merged commit 637d509 into main Jul 29, 2026
1 check passed
@temrjan
temrjan deleted the feat/bot-start-webhook branch July 29, 2026 16:47
temrjan added a commit that referenced this pull request Jul 29, 2026
…ant webhook (#56) (#58)

* Revert "feat(api): telegram /start webhook with inline Mini App launch button (#56)"

This reverts commit 637d509.

* feat(bot): hide AI assistant from /start (demo scope)

The existing polling bot exposed the AI assistant — a launch-keyboard button
and an "AI assistant" line in every welcome. The demo hides the assistant, so
drop the button, its aylin i18n key, and the welcome line in uz/ru/en. The
launch keyboard keeps Wallet / Exchange / Staking / Send.

Adds test_bot.py (red->green): asserts no assistant word survives in the
keyboard or welcome copy, and the wallet launch button still points at the app.

---------

Co-authored-by: temrjan <x.temrjan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant