mirror of
https://github.com/prdlk/vortex.git
synced 2026-08-04 02:11:43 +00:00
feat: unified messaging TUI MVP — Synapse + 7 mautrix bridges + Textual TUI + MCP draft staging
One-command local stack: cp .env.example .env && make up. Idempotent bootstrap renders Synapse + bridge configs from pristine upstream examples, provisions databases, registrations, double puppeting, and the admin user. Textual TUI with bridge manager, in-terminal QR login, and drafts panel. MCP server exposes read tools and a human-gated draft send workflow. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"""Render QR-ish message payloads as unicode half-block QR codes."""
|
||||
|
||||
import qrcode
|
||||
|
||||
QR_SCHEMES = ("https://wa.me/", "gmessages://")
|
||||
|
||||
|
||||
def looks_like_qr_payload(body: str, sender_is_bridge_bot: bool) -> bool:
|
||||
"""Deliberately simple heuristic:
|
||||
|
||||
- message starts with a known pairing scheme (whatsapp / gmessages), or
|
||||
- a bridge-bot message that is a single URL/token: 20-199 chars, no
|
||||
whitespace, and either contains '://' or is alnum-ish (pairing code).
|
||||
"""
|
||||
body = body.strip()
|
||||
if body.startswith(QR_SCHEMES):
|
||||
return True
|
||||
if sender_is_bridge_bot and 20 <= len(body) < 200 and not any(c.isspace() for c in body):
|
||||
return "://" in body or body.replace("-", "").replace("_", "").isalnum()
|
||||
return False
|
||||
|
||||
|
||||
def render_qr(text: str) -> str:
|
||||
"""QR code as text, two matrix rows per output line via half blocks."""
|
||||
qr = qrcode.QRCode(border=1)
|
||||
qr.add_data(text)
|
||||
qr.make(fit=True)
|
||||
matrix = qr.get_matrix()
|
||||
if len(matrix) % 2:
|
||||
matrix.append([False] * len(matrix[0]))
|
||||
chars = {(True, True): "█", (True, False): "▀", (False, True): "▄", (False, False): " "}
|
||||
return "\n".join(
|
||||
"".join(chars[(top[x], bottom[x])] for x in range(len(top)))
|
||||
for top, bottom in zip(matrix[::2], matrix[1::2])
|
||||
)
|
||||
Reference in New Issue
Block a user