dsh-tg-bridge 1.2.8 → 1.2.9
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 +10 -2
- package/package.json +5 -3
- package/queue-notice.mjs +10 -0
package/bridge.mjs
CHANGED
|
@@ -22,6 +22,7 @@ import dns from 'node:dns';
|
|
|
22
22
|
import net from 'node:net';
|
|
23
23
|
dns.setDefaultResultOrder('ipv4first');
|
|
24
24
|
net.setDefaultAutoSelectFamily(false);
|
|
25
|
+
import { noticeIsObsolete } from './queue-notice.mjs';
|
|
25
26
|
import { handleControl, CONTROL_COMMANDS } from './control.mjs';
|
|
26
27
|
import { renderPrices } from './prices.mjs';
|
|
27
28
|
import { t, resolveLang } from './i18n.mjs';
|
|
@@ -1751,6 +1752,10 @@ async function main() {
|
|
|
1751
1752
|
// handled inline and must stay silent about it.
|
|
1752
1753
|
msg.text || msg.caption
|
|
1753
1754
|
? async () => {
|
|
1755
|
+
// Which turn was running when this message was queued: if that
|
|
1756
|
+
// value changes, the queued turn has started and the notice is
|
|
1757
|
+
// already obsolete.
|
|
1758
|
+
const turnWhenQueued = turnStartedAt.get(queueKey);
|
|
1754
1759
|
await new Promise((resolve) => setTimeout(resolve, Number(config.busyNoticeMs ?? 45000)));
|
|
1755
1760
|
if (!queues.has(queueKey)) return; // already finished
|
|
1756
1761
|
// One notice per topic: a second queued message must not add a
|
|
@@ -1767,8 +1772,11 @@ async function main() {
|
|
|
1767
1772
|
thread,
|
|
1768
1773
|
);
|
|
1769
1774
|
if (messageId) busyNotices.set(queueKey, { chatId: msg.chat.id, messageId });
|
|
1770
|
-
// The turn may have started while the notice was in flight
|
|
1771
|
-
|
|
1775
|
+
// The queued turn may have started while the notice was in flight;
|
|
1776
|
+
// in that case nothing else will delete it until the turn ends.
|
|
1777
|
+
if (noticeIsObsolete(turnWhenQueued, turnStartedAt.get(queueKey), queues.has(queueKey))) {
|
|
1778
|
+
await clearBusyNotice(queueKey);
|
|
1779
|
+
}
|
|
1772
1780
|
}
|
|
1773
1781
|
: undefined,
|
|
1774
1782
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-tg-bridge",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
4
4
|
"description": "Telegram bridge for DeepSeek Harness: text, voice, photos and project-per-topic sessions without opening the desktop app",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "bridge.mjs",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"setup": "node setup.mjs",
|
|
13
13
|
"check": "node setup.mjs --check",
|
|
14
14
|
"menu": "node bot-menu.mjs",
|
|
15
|
-
"doctor": "node bridge-kick.mjs"
|
|
15
|
+
"doctor": "node bridge-kick.mjs",
|
|
16
|
+
"test": "node --test"
|
|
16
17
|
},
|
|
17
18
|
"engines": {
|
|
18
19
|
"node": ">=20"
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
"README.md",
|
|
44
45
|
"LICENSE",
|
|
45
46
|
"config.example.json",
|
|
46
|
-
"patches/"
|
|
47
|
+
"patches/",
|
|
48
|
+
"queue-notice.mjs"
|
|
47
49
|
]
|
|
48
50
|
}
|
package/queue-notice.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// When is a "your message is queued" notice already obsolete?
|
|
2
|
+
//
|
|
3
|
+
// It was written for a specific running turn (`turnWhenQueued`). It must go as
|
|
4
|
+
// soon as that turn is no longer the one in front: either the queue drained, or
|
|
5
|
+
// the queued turn started (its start time differs). Kept in its own module so
|
|
6
|
+
// the rule can be tested without starting the bridge or talking to Telegram.
|
|
7
|
+
|
|
8
|
+
export function noticeIsObsolete(turnWhenQueued, turnNow, stillQueued) {
|
|
9
|
+
return !stillQueued || turnNow !== turnWhenQueued;
|
|
10
|
+
}
|