mirror of
https://github.com/BEARlogin/max-telegram-bridge-bot.git
synced 2026-04-28 03:39:46 +00:00
Issue #38 part 2. Allows using multiple MAX group chats as per-thread mirrors of a TG forum group, since MAX has no native thread concept. - New table thread_pairs (tg_chat_id, tg_thread_id, max_chat_id) with unique(max_chat_id) — one MAX chat = at most one TG thread. - pending gains thread_id column for thread-bridge key exchange. - Repo methods: StartThreadBridge (TG issues key), CompleteThreadBridge (MAX consumes key), GetThreadMaxChat, GetThreadTgPair, UnpairThread, UnpairThreadByMax. - Commands: * /thread_bridge in a TG forum thread (admin, non-General) -> key * /thread_bridge <key> in a MAX chat -> binds * /thread_unbridge on either side TG's BOT_COMMAND_INVALID rule forbids hyphens, so the commands use underscore. - Routing priority: thread-bridge > regular pair. TG->MAX: if msg.MessageThreadID has a thread_pair, route there. MAX->TG: if MAX chat is in thread_pairs, route to (tg_chat, thread). - For thread-paired MAX chats, the Part 1 reply-to-source-thread override is disabled: thread-paired chats have a fixed target thread, replies stay there. - Safeguard: a MAX chat cannot be in both pairs and thread_pairs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
12 lines
428 B
SQL
12 lines
428 B
SQL
ALTER TABLE pending ADD COLUMN thread_id INTEGER NOT NULL DEFAULT 0;
|
|
|
|
CREATE TABLE thread_pairs (
|
|
tg_chat_id INTEGER NOT NULL,
|
|
tg_thread_id INTEGER NOT NULL,
|
|
max_chat_id INTEGER NOT NULL,
|
|
created_at INTEGER NOT NULL DEFAULT 0,
|
|
PRIMARY KEY (tg_chat_id, tg_thread_id)
|
|
);
|
|
|
|
CREATE UNIQUE INDEX idx_thread_pairs_max ON thread_pairs(max_chat_id);
|
|
CREATE INDEX idx_thread_pairs_tg ON thread_pairs(tg_chat_id);
|