dsh-tg-bridge 1.33.1 → 1.33.2
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/callbacks.mjs +1 -1
- package/i18n/en/core.mjs +1 -0
- package/i18n/ru/core.mjs +1 -0
- package/i18n/zh/core.mjs +1 -0
- package/package.json +1 -1
- package/settings-card.mjs +5 -1
- package/settings-press.mjs +14 -12
package/callbacks.mjs
CHANGED
|
@@ -76,7 +76,7 @@ export async function handleCallback(query) {
|
|
|
76
76
|
// The settings card. Its own answer path, because a tap that redraws or
|
|
77
77
|
// flips one setting must not go through the defaults below (`clearKeyboard`
|
|
78
78
|
// would strip the tabs it is about to draw again).
|
|
79
|
-
await handleCardPress(query, { chatId, messageId, threadId, key, lang, answer
|
|
79
|
+
await handleCardPress(query, { chatId, messageId, threadId, key, lang, answer });
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
|
package/i18n/en/core.mjs
CHANGED
|
@@ -75,6 +75,7 @@ export default {
|
|
|
75
75
|
'settings.reply.setBound': 'This topic uses set {name}: model, effort, permissions and preset come from it.',
|
|
76
76
|
'settings.card.changed': '✓ {label}: {value}',
|
|
77
77
|
'settings.card.stale': 'That button is from an older version of the card. Open /settings again.',
|
|
78
|
+
'settings.card.same': 'Already set',
|
|
78
79
|
'btn.stop': 'Stop',
|
|
79
80
|
'btn.logs': 'Logs',
|
|
80
81
|
'btn.retry': 'Retry',
|
package/i18n/ru/core.mjs
CHANGED
|
@@ -75,6 +75,7 @@ export default {
|
|
|
75
75
|
'settings.reply.setBound': 'Тема использует набор {name}: модель, усилие, права и пресет берутся из него.',
|
|
76
76
|
'settings.card.changed': '✓ {label}: {value}',
|
|
77
77
|
'settings.card.stale': 'Эта кнопка из старой версии карточки. Открой /settings заново.',
|
|
78
|
+
'settings.card.same': 'Уже так и стоит',
|
|
78
79
|
'btn.stop': 'Стоп',
|
|
79
80
|
'btn.logs': 'Логи',
|
|
80
81
|
'btn.retry': 'Повторить',
|
package/i18n/zh/core.mjs
CHANGED
|
@@ -75,6 +75,7 @@ export default {
|
|
|
75
75
|
'settings.reply.setBound': '本话题使用组合 {name}:模型、力度、权限、预设都来自它。',
|
|
76
76
|
'settings.card.changed': '✓ {label}:{value}',
|
|
77
77
|
'settings.card.stale': '这个按钮来自旧版卡片。请重新打开 /settings。',
|
|
78
|
+
'settings.card.same': '已经是这样',
|
|
78
79
|
'btn.stop': '停止',
|
|
79
80
|
'btn.logs': '日志',
|
|
80
81
|
'btn.retry': '重试',
|
package/package.json
CHANGED
package/settings-card.mjs
CHANGED
|
@@ -271,7 +271,11 @@ export function commandFor({ t, current = {}, updateMode = 'check' }, data) {
|
|
|
271
271
|
// The way out is not a setting: it removes the card, which is the one action
|
|
272
272
|
// the buttons could not do while a press turned the card into a line.
|
|
273
273
|
if (row === 'done' && !value) return { done: true };
|
|
274
|
-
|
|
274
|
+
// A tab carries its own page. It did not, and the press asked the renderer for
|
|
275
|
+
// `undefined`, which fell back to `reply`: every tab redrew the page already on
|
|
276
|
+
// screen, Telegram answered "message is not modified", and the only symptom was
|
|
277
|
+
// a menu that did nothing. The page belongs in the answer, not in the caller.
|
|
278
|
+
if (SETTINGS_PAGES.includes(row) && !value) return { tab: row, page: row };
|
|
275
279
|
const button = settingsButtons({ t, current, updateMode }).find((b) => b.id === row && (b.value || '') === value);
|
|
276
280
|
if (!button || !button.command) return null;
|
|
277
281
|
return {
|
package/settings-press.mjs
CHANGED
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
// Two rules hold for every path below, and they are the reason the code is
|
|
10
10
|
// shaped like this rather than shorter:
|
|
11
11
|
//
|
|
12
|
-
// - A press says something.
|
|
13
|
-
//
|
|
14
|
-
// never mistaken for a dead menu.
|
|
12
|
+
// - A press says something. Every path ends in `answer(...)`, and that call is
|
|
13
|
+
// what reports the output to the guard the router created — a press that
|
|
14
|
+
// fails, hangs or finds a stale button is never mistaken for a dead menu.
|
|
15
15
|
// - A press is fast. Every call here is `tgFast`: a card lives inside a tap, and
|
|
16
16
|
// the person watching it will not wait the three minutes `tg` allows.
|
|
17
17
|
import { AgentsetStore } from './agentsets.mjs';
|
|
@@ -37,7 +37,6 @@ export async function handleCardPress(query, ctx) {
|
|
|
37
37
|
const answer =
|
|
38
38
|
ctx.answer ??
|
|
39
39
|
((text, show = false) => tgFast('answerCallbackQuery', { callback_query_id: query.id, text, show_alert: show }).catch(() => false));
|
|
40
|
-
const mark = ctx.mark ?? (() => {});
|
|
41
40
|
|
|
42
41
|
if (!wanted) {
|
|
43
42
|
log(`settings press ${data}: stale button, the card no longer has it`);
|
|
@@ -47,7 +46,6 @@ export async function handleCardPress(query, ctx) {
|
|
|
47
46
|
|
|
48
47
|
if (wanted.done) {
|
|
49
48
|
await tgFast('deleteMessage', { chat_id: chatId, message_id: messageId }).catch((error) => log(`settings card delete failed: ${error.message}`));
|
|
50
|
-
mark();
|
|
51
49
|
await answer('');
|
|
52
50
|
return;
|
|
53
51
|
}
|
|
@@ -62,7 +60,7 @@ export async function handleCardPress(query, ctx) {
|
|
|
62
60
|
bound: boundSetOf(key),
|
|
63
61
|
note,
|
|
64
62
|
});
|
|
65
|
-
|
|
63
|
+
let same = false;
|
|
66
64
|
await tgFast('editMessageText', {
|
|
67
65
|
chat_id: chatId,
|
|
68
66
|
message_id: messageId,
|
|
@@ -71,14 +69,18 @@ export async function handleCardPress(query, ctx) {
|
|
|
71
69
|
...(threadId > 0 ? { message_thread_id: threadId } : {}),
|
|
72
70
|
}).catch((error) => {
|
|
73
71
|
const why = String(error.message || '');
|
|
74
|
-
// Tapping the
|
|
72
|
+
// Tapping the value already in force is not a failure: Telegram refuses an
|
|
75
73
|
// edit that changes nothing, and the card is already what the press asked
|
|
76
|
-
// for. It is still worth a
|
|
77
|
-
//
|
|
78
|
-
if (/message is not modified/i.test(why))
|
|
79
|
-
|
|
74
|
+
// for. It is still worth a word, because the person pressed a live button
|
|
75
|
+
// and silence is what a broken card looks like.
|
|
76
|
+
if (/message is not modified/i.test(why)) {
|
|
77
|
+
same = true;
|
|
78
|
+
log(`settings card ${page}: already showed that`);
|
|
79
|
+
} else {
|
|
80
|
+
log(`settings card redraw failed: ${why}`);
|
|
81
|
+
}
|
|
80
82
|
});
|
|
81
|
-
await answer('');
|
|
83
|
+
await answer(same ? t(lang, 'settings.card.same') : '');
|
|
82
84
|
};
|
|
83
85
|
|
|
84
86
|
if (wanted.tab) {
|