Repository navigation
feat(bot): Telegram bot over the Basira API - #2
Merged
Merged
Conversation
Thin client (python-telegram-bot 22) over POST /v1/check and /v1/check/image: status, verbatim source_text + reference, bold differences from the API diff, links, transparency line. No model, no storage (ADR-004), all prose from messages/*.json. Groups: /check (reply or argument). Polling default (E-059). Measured: ruff + mypy --strict clean, 73 tests; live 11/11 private scenarios, channel forward and group /check against https://basirapp.site.
Each result is one RTL rich message: heading + status strip, the user's quote as a cited blockquote, source_text as a verbatim pull-quote credited with ref_label_ar (one per ayah), <mark> from the API diff, a compact metadata table, collapsible notices / other positions / full record, url and copy buttons. Classic HTML stays as the automatic fallback (BOT_RICH=0 forces it). Measured: 105 tests (Rich-HTML validation, lexicon, limits, fallback); live 16/16 scenarios on the rich path, 0 rich calls rejected (E-060). Evidence rendered from the blocks Telegram stored: docs/design/evidence/telegram/.
MoTechSys
force-pushed
the
feat/telegram-bot
branch
from
October 6, 2026 00:55
269cddb to
a161e46
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
integrations/telegram/: Telegram bot @BasiraCheckBot, a thin client overPOST /v1/checkandPOST /v1/check/image. No model, no storage (ADR-004). Every sentence comes frommessages/ar.json;source_textandref_label_arare inserted verbatim; bold ranges come from the APIdiff, widened to whole letter clusters so harakat are never split.Also:
make bot-install/make bot-test, CI jobbot, optional compose servicetelegram-bot(profiles: [bot]), docs (INTEGRATIONS §4, README, CHANGELOG Unreleased, DECISIONS E-059, one line in AI_USAGE §1).backend/andfrontend/untouched.Measured
ruff check . && ruff format --check . && mypy --strict . && pytest -q→ 73 passed, 0 errors. Handlers run through the real PTBApplication, with Telegram faked at the HTTP layer. Fixtures are real API responses from basirapp.site.make lintin the root: green.scripts/live_e2e.py): 11/11 — start, found, needs_review (bold «علي» / «عَلَىٰ»), not_found + Dorar/Shamela links, partial_match, refusal (refusal notice only), no quotes, /sources, /limits, unsupported file, image → OCR text +needs_review/image_unconfirmed./checkas a reply ✅,/checkwith nothing → usage ✅.git grep -nE "[0-9]{8,}:[A-Za-z0-9_-]{30,}"→ empty.Known limit
/check.Suggestions for the frontend
?text=on/checkto enable an "Open this text in Basira" button. The bot currently links to/checkwithout the text.Update — Rich Messages layout (E-060)
Each reply is now one RTL Telegram Rich Message (Bot API 10.3): a heading with a status strip, your text as a cited blockquote, the source verbatim as a pull-quote with its reference as the credit (one per ayah), the differences marked with
<mark>taken from the APIdiff, a compact metadata table, collapsible notes / other positions / full record, and buttons for the source, search and copy. If the rich call is rejected, the bot falls back to classic HTML automatically.main(PR feat(engine): understand text as people type it — rasm-uniqueness proof (D-015) + unmarked-quote detection (E-057/E-058) #1); conflicts resolved, keeping both changes. CI is green.docs/design/evidence/telegram/.