dsh-tg-bridge 1.19.9 → 1.19.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bridge.mjs +31 -0
- package/i18n/en.mjs +1 -0
- package/i18n/ru.mjs +1 -0
- package/i18n/zh.mjs +1 -0
- package/package.json +1 -1
package/bridge.mjs
CHANGED
|
@@ -736,6 +736,19 @@ function commandOf(text) {
|
|
|
736
736
|
return `/${match[1].toLowerCase().replace(/[.-]+/g, '')}`;
|
|
737
737
|
}
|
|
738
738
|
|
|
739
|
+
/**
|
|
740
|
+
* Commands that may run from the General topic without changing anything there.
|
|
741
|
+
*
|
|
742
|
+
* The lobby rule moves a General message into the newest topic; for these that is
|
|
743
|
+
* the whole point (you want the status of the work you are looking at, and `/stop`
|
|
744
|
+
* must work from anywhere). Everything else is answered in General with the name
|
|
745
|
+
* of the topic it would have changed.
|
|
746
|
+
*/
|
|
747
|
+
const GENERAL_SAFE = new Set([
|
|
748
|
+
'status', 'sessions', 'branches', 'jobs', 'version', 'doctor', 'logs',
|
|
749
|
+
'stop', 'help', 'menu', 'prices', 'thoughts',
|
|
750
|
+
]);
|
|
751
|
+
|
|
739
752
|
/** Canonical immediate command name for a message, or '' when it must queue. */
|
|
740
753
|
function immediateCommandOf(text) {
|
|
741
754
|
const trimmed = String(text ?? '').trim();
|
|
@@ -1530,6 +1543,9 @@ async function handleMessage(msg, album = null) {
|
|
|
1530
1543
|
}
|
|
1531
1544
|
|
|
1532
1545
|
let threadId = threadOf(msg);
|
|
1546
|
+
// Whether the person typed in the General topic (the "All" stream), before the
|
|
1547
|
+
// lobby rule below moves the message into a topic.
|
|
1548
|
+
const typedInGeneral = threadId === 0;
|
|
1533
1549
|
// 3. The General-chat twin of an already-seeded topic: keep the log line,
|
|
1534
1550
|
// skip the turn — the topic message already owns this work.
|
|
1535
1551
|
const twin = threadId === 0 ? topicSeededRecently(msg.text ?? msg.caption ?? '') : 0;
|
|
@@ -1550,6 +1566,8 @@ async function handleMessage(msg, album = null) {
|
|
|
1550
1566
|
threadId = recovered;
|
|
1551
1567
|
}
|
|
1552
1568
|
}
|
|
1569
|
+
// The topic a General message was moved into, or 0 when it stayed where it was.
|
|
1570
|
+
const recoveredTopic = typedInGeneral && threadId > 0 ? threadId : 0;
|
|
1553
1571
|
touchTopic(threadId);
|
|
1554
1572
|
|
|
1555
1573
|
const key = sessionKey(chatId, threadId);
|
|
@@ -1645,6 +1663,19 @@ async function handleMessage(msg, album = null) {
|
|
|
1645
1663
|
}
|
|
1646
1664
|
if (effectiveArg === 'restartconfirm' || effectiveArg === 'restart.confirm') effectiveArg = 'restart confirm';
|
|
1647
1665
|
|
|
1666
|
+
// General is the lobby: a prompt written there runs in the most recently active
|
|
1667
|
+
// topic so one project stays in one place. A command that CHANGES things must
|
|
1668
|
+
// not silently change a topic the person is not looking at — `/new` there wiped
|
|
1669
|
+
// the session of another topic and `/rewind` rolled one back, and the answer
|
|
1670
|
+
// appeared in that topic rather than where it was typed. Reading commands and
|
|
1671
|
+
// `/stop` still follow the work, because that is what the lobby is for.
|
|
1672
|
+
if (recoveredTopic > 0 && effective && !GENERAL_SAFE.has(effective.slice(1))) {
|
|
1673
|
+
const named = topicName(chatId, recoveredTopic) || `#${recoveredTopic}`;
|
|
1674
|
+
log(`refused ${effective} in General; it belongs to topic ${recoveredTopic}`);
|
|
1675
|
+
await send(chatId, t(lang, 'msg.generalGuard', { cmd: effective, topic: named }), 0);
|
|
1676
|
+
return;
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1648
1679
|
// An unknown slash command must never become an AI turn: it burns money and
|
|
1649
1680
|
// answers something the person did not ask. Answer with the menu instead.
|
|
1650
1681
|
if (command && !effective) {
|
package/i18n/en.mjs
CHANGED
|
@@ -214,6 +214,7 @@ export default {
|
|
|
214
214
|
'msg.restarted': 'Bridge restarted — back online (pid {pid}).\nThe topic and session are the same; keep going.',
|
|
215
215
|
'cmd.restart.prompt': 'To restart the bridge: /restart confirm. For the DSH app: /app restart confirm.',
|
|
216
216
|
'cmd.restart.started': 'Restarting the bridge…',
|
|
217
|
+
'msg.generalGuard': "This is the General topic, where topics are started. {cmd} changes “{topic}”, so open that topic and send it there. Reading works here: /status, /sessions, /stop.",
|
|
217
218
|
'msg.unknownCommand': 'Unknown command: {cmd}. Open /help — it lists everything this bot can do.',
|
|
218
219
|
'msg.langSet': 'Language set to English.',
|
|
219
220
|
'msg.reasoningOn': 'Working notes on: 💭 lines will appear in the progress message.\nOff: /reasoning off',
|
package/i18n/ru.mjs
CHANGED
|
@@ -214,6 +214,7 @@ export default {
|
|
|
214
214
|
'msg.restarted': 'Мост перезапущен — на связи (pid {pid}).\nТема и сессия прежние, можно продолжать.',
|
|
215
215
|
'cmd.restart.prompt': 'Перезапуск моста: /restart confirm. Приложение DSH: /app restart confirm.',
|
|
216
216
|
'cmd.restart.started': 'Перезапускаю мост…',
|
|
217
|
+
'msg.generalGuard': "Это общая тема «Все» — здесь темы начинаются. {cmd} меняет «{topic}», поэтому откройте ту тему и отправьте команду там. Читать можно и здесь: /status, /sessions, /stop.",
|
|
217
218
|
'msg.unknownCommand': 'Неизвестная команда: {cmd}. Открой /help — там всё, что умеет бот.',
|
|
218
219
|
'msg.langSet': 'Язык переключён на русский.',
|
|
219
220
|
'msg.reasoningOn': 'Заметки по ходу включены: 💭 будут появляться в сообщении прогресса.\nВыключить: /reasoning off',
|
package/i18n/zh.mjs
CHANGED
|
@@ -214,6 +214,7 @@ export default {
|
|
|
214
214
|
'msg.restarted': '桥已重启,连接正常(pid {pid})。\n主题和会话不变,可以继续。',
|
|
215
215
|
'cmd.restart.prompt': '重启桥:/restart confirm。重启 DSH 应用:/app restart confirm。',
|
|
216
216
|
'cmd.restart.started': '正在重启桥…',
|
|
217
|
+
'msg.generalGuard': "这里是「全部」主题,用来开新话题。{cmd} 会改动「{topic}」,请打开那个话题再发送。这里可以直接读:/status、/sessions、/stop。",
|
|
217
218
|
'msg.unknownCommand': '未知命令:{cmd}。打开 /help 查看机器人支持的全部命令。',
|
|
218
219
|
'msg.langSet': '界面语言已切换为中文。',
|
|
219
220
|
'msg.reasoningOn': '工作记录已开启:💭 会显示在进度消息里。\n关闭:/reasoning off',
|
package/package.json
CHANGED