@a1hvdy/cc-openclaw 0.24.0 → 0.25.1
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/dist/src/channels/telegram-mirror/burst-accumulator.d.ts +96 -0
- package/dist/src/channels/telegram-mirror/burst-accumulator.js +130 -0
- package/dist/src/channels/telegram-mirror/burst-accumulator.js.map +1 -0
- package/dist/src/channels/telegram-mirror/callback-mapping.d.ts +61 -0
- package/dist/src/channels/telegram-mirror/callback-mapping.js +99 -0
- package/dist/src/channels/telegram-mirror/callback-mapping.js.map +1 -0
- package/dist/src/channels/telegram-mirror/card-renderer.d.ts +74 -0
- package/dist/src/channels/telegram-mirror/card-renderer.js +131 -0
- package/dist/src/channels/telegram-mirror/card-renderer.js.map +1 -0
- package/dist/src/channels/telegram-mirror/commands.d.ts +142 -0
- package/dist/src/channels/telegram-mirror/commands.js +389 -0
- package/dist/src/channels/telegram-mirror/commands.js.map +1 -0
- package/dist/src/channels/telegram-mirror/compose-buffer.d.ts +71 -0
- package/dist/src/channels/telegram-mirror/compose-buffer.js +110 -0
- package/dist/src/channels/telegram-mirror/compose-buffer.js.map +1 -0
- package/dist/src/channels/telegram-mirror/cost-views.d.ts +58 -0
- package/dist/src/channels/telegram-mirror/cost-views.js +121 -0
- package/dist/src/channels/telegram-mirror/cost-views.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/callback-data-overflow.d.ts +21 -0
- package/dist/src/channels/telegram-mirror/failure/callback-data-overflow.js +30 -0
- package/dist/src/channels/telegram-mirror/failure/callback-data-overflow.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/gateway-down.d.ts +15 -0
- package/dist/src/channels/telegram-mirror/failure/gateway-down.js +27 -0
- package/dist/src/channels/telegram-mirror/failure/gateway-down.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/in-flight-conflict.d.ts +15 -0
- package/dist/src/channels/telegram-mirror/failure/in-flight-conflict.js +27 -0
- package/dist/src/channels/telegram-mirror/failure/in-flight-conflict.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/index.d.ts +23 -0
- package/dist/src/channels/telegram-mirror/failure/index.js +35 -0
- package/dist/src/channels/telegram-mirror/failure/index.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/model-5xx.d.ts +16 -0
- package/dist/src/channels/telegram-mirror/failure/model-5xx.js +24 -0
- package/dist/src/channels/telegram-mirror/failure/model-5xx.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/network-blip.d.ts +17 -0
- package/dist/src/channels/telegram-mirror/failure/network-blip.js +25 -0
- package/dist/src/channels/telegram-mirror/failure/network-blip.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/pool-exhausted-fallback.d.ts +15 -0
- package/dist/src/channels/telegram-mirror/failure/pool-exhausted-fallback.js +24 -0
- package/dist/src/channels/telegram-mirror/failure/pool-exhausted-fallback.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/rate-limit.d.ts +16 -0
- package/dist/src/channels/telegram-mirror/failure/rate-limit.js +26 -0
- package/dist/src/channels/telegram-mirror/failure/rate-limit.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/returning-after-24h.d.ts +14 -0
- package/dist/src/channels/telegram-mirror/failure/returning-after-24h.js +33 -0
- package/dist/src/channels/telegram-mirror/failure/returning-after-24h.js.map +1 -0
- package/dist/src/channels/telegram-mirror/failure/types.d.ts +30 -0
- package/dist/src/channels/telegram-mirror/failure/types.js +9 -0
- package/dist/src/channels/telegram-mirror/failure/types.js.map +1 -0
- package/dist/src/channels/telegram-mirror/inbound-handler.d.ts +52 -0
- package/dist/src/channels/telegram-mirror/inbound-handler.js +115 -0
- package/dist/src/channels/telegram-mirror/inbound-handler.js.map +1 -0
- package/dist/src/channels/telegram-mirror/index.d.ts +30 -0
- package/dist/src/channels/telegram-mirror/index.js +49 -0
- package/dist/src/channels/telegram-mirror/index.js.map +1 -0
- package/dist/src/channels/telegram-mirror/plan-attachment.d.ts +120 -0
- package/dist/src/channels/telegram-mirror/plan-attachment.js +138 -0
- package/dist/src/channels/telegram-mirror/plan-attachment.js.map +1 -0
- package/dist/src/channels/telegram-mirror/quota-reader.d.ts +41 -0
- package/dist/src/channels/telegram-mirror/quota-reader.js +29 -0
- package/dist/src/channels/telegram-mirror/quota-reader.js.map +1 -0
- package/dist/src/channels/telegram-mirror/sessions-keyboard.d.ts +84 -0
- package/dist/src/channels/telegram-mirror/sessions-keyboard.js +113 -0
- package/dist/src/channels/telegram-mirror/sessions-keyboard.js.map +1 -0
- package/dist/src/channels/telegram-mirror/soak-log.d.ts +98 -0
- package/dist/src/channels/telegram-mirror/soak-log.js +136 -0
- package/dist/src/channels/telegram-mirror/soak-log.js.map +1 -0
- package/dist/src/channels/telegram-mirror/state-machine.d.ts +102 -0
- package/dist/src/channels/telegram-mirror/state-machine.js +117 -0
- package/dist/src/channels/telegram-mirror/state-machine.js.map +1 -0
- package/dist/src/channels/telegram-mirror/sync-commands.d.ts +63 -0
- package/dist/src/channels/telegram-mirror/sync-commands.js +51 -0
- package/dist/src/channels/telegram-mirror/sync-commands.js.map +1 -0
- package/dist/src/channels/telegram-mirror/threshold-watcher.d.ts +54 -0
- package/dist/src/channels/telegram-mirror/threshold-watcher.js +77 -0
- package/dist/src/channels/telegram-mirror/threshold-watcher.js.map +1 -0
- package/dist/src/command-router/cc-handler.js +1 -1
- package/dist/src/command-router/cc-handler.js.map +1 -1
- package/dist/src/index.js +12 -8
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/auto-recovery.js +1 -1
- package/dist/src/lib/auto-recovery.js.map +1 -1
- package/dist/src/lib/drift-detector.js +1 -1
- package/dist/src/lib/drift-detector.js.map +1 -1
- package/dist/src/lib/error-renderer.d.ts +23 -0
- package/dist/src/lib/error-renderer.js +106 -0
- package/dist/src/lib/error-renderer.js.map +1 -0
- package/dist/src/lib/perf/speculative-bubble.d.ts +27 -0
- package/dist/src/lib/perf/speculative-bubble.js +36 -0
- package/dist/src/lib/perf/speculative-bubble.js.map +1 -0
- package/dist/src/lib/session-registry.d.ts +66 -0
- package/dist/src/lib/session-registry.js +188 -0
- package/dist/src/lib/session-registry.js.map +1 -0
- package/dist/src/lib/telegram-bot-api.d.ts +100 -0
- package/dist/src/lib/telegram-bot-api.js +204 -0
- package/dist/src/lib/telegram-bot-api.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/lib/telegram-bot-api.ts — v0.25.0 M16 extracted HTTP layer.
|
|
3
|
+
*
|
|
4
|
+
* Pre-M16 the Telegram Bot API helpers lived inside the legacy live-card +
|
|
5
|
+
* card-renderer modules. M16 deletes those modules, but a handful of lib/
|
|
6
|
+
* utilities (error-renderer.ts, perf/speculative-bubble.ts) still need to
|
|
7
|
+
* dispatch Telegram messages. This file is the migrated, slim HTTP layer:
|
|
8
|
+
* • telegramApi(method, params) — generic POST to api.telegram.org
|
|
9
|
+
* • sendTg(chatId, text, ...) — sendMessage with MarkdownV2 + plain
|
|
10
|
+
* text fallback (preserves v0.20.1
|
|
11
|
+
* content-punctuation fix).
|
|
12
|
+
* • editTg(chatId, msgId, text…) — editMessageText with same fallback +
|
|
13
|
+
* 429 retry handling.
|
|
14
|
+
* • BOT_TOKEN exported as a mutable getter (mutated via setBotToken /
|
|
15
|
+
* initBotTokenFromConfig at boot).
|
|
16
|
+
*
|
|
17
|
+
* Token sourcing on boot (initBotTokenFromConfig):
|
|
18
|
+
* 1. api.config.channels.telegram.accounts[defaultAccount].botToken
|
|
19
|
+
* 2. ~/.openclaw/openclaw.json → same JSON path
|
|
20
|
+
* 3. fallthrough: BOT_TOKEN stays '' and renderer/sendTg return false.
|
|
21
|
+
*
|
|
22
|
+
* The mirror channel's register() (M0..M14 + M15-cutover-default) calls
|
|
23
|
+
* initBotTokenFromConfig(api) at boot — the same shape the legacy live-card
|
|
24
|
+
* used to do.
|
|
25
|
+
*/
|
|
26
|
+
export declare const OPENCLAW_CONFIG_PATH: string;
|
|
27
|
+
/**
|
|
28
|
+
* Mutable getter for the current bot token. Callers should treat it as
|
|
29
|
+
* read-only at runtime; use setBotToken / initBotTokenFromConfig to mutate.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getBotToken(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Imperative setter — for tests + explicit init paths. Returns the
|
|
34
|
+
* previous value so test cleanup can restore.
|
|
35
|
+
*/
|
|
36
|
+
export declare function setBotToken(token: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Back-compat alias — legacy code did `import { BOT_TOKEN } from ...`. We
|
|
39
|
+
* preserve the binding via a frozen wrapper that always reflects the
|
|
40
|
+
* current token. Existing read-sites get the current value; existing
|
|
41
|
+
* write-sites (none expected — legacy only wrote via setBotToken under
|
|
42
|
+
* a different name) would need migration.
|
|
43
|
+
*
|
|
44
|
+
* Using a getter-backed object also lets `if (!BOT_TOKEN)` work
|
|
45
|
+
* idiomatically; the property is read on every access.
|
|
46
|
+
*/
|
|
47
|
+
export declare const BOT_TOKEN: {
|
|
48
|
+
readonly value: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Boot-time initialiser. Reads the configured Telegram bot token from
|
|
52
|
+
* either api.config.channels.telegram.accounts or ~/.openclaw/openclaw.json.
|
|
53
|
+
* Returns true when a token was loaded.
|
|
54
|
+
*/
|
|
55
|
+
export interface BotConfigSource {
|
|
56
|
+
config?: {
|
|
57
|
+
channels?: {
|
|
58
|
+
telegram?: {
|
|
59
|
+
defaultAccount?: string;
|
|
60
|
+
accounts?: Record<string, {
|
|
61
|
+
botToken?: string;
|
|
62
|
+
}>;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
logger?: {
|
|
67
|
+
info: (msg: string) => void;
|
|
68
|
+
warn: (msg: string) => void;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export declare function initBotTokenFromConfig(api?: BotConfigSource): boolean;
|
|
72
|
+
export interface TelegramApiResponse {
|
|
73
|
+
ok: boolean;
|
|
74
|
+
result?: {
|
|
75
|
+
message_id?: number;
|
|
76
|
+
};
|
|
77
|
+
error_code?: number;
|
|
78
|
+
description?: string;
|
|
79
|
+
parameters?: {
|
|
80
|
+
retry_after?: number;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Low-level POST to api.telegram.org. Resolves with the parsed JSON
|
|
85
|
+
* response, or {ok:false} on JSON parse failure / network error
|
|
86
|
+
* (rejection is the caller's signal for a truly unreachable endpoint).
|
|
87
|
+
*/
|
|
88
|
+
export declare function telegramApi(method: string, params: Record<string, unknown>): Promise<TelegramApiResponse>;
|
|
89
|
+
/**
|
|
90
|
+
* sendMessage with MarkdownV2 first + plain-text fallback. The fallback
|
|
91
|
+
* is the v0.20.1 fix: prior implementation stripped punctuation on
|
|
92
|
+
* MarkdownV2 parse errors; current behaviour retries with parse_mode
|
|
93
|
+
* omitted so all content survives.
|
|
94
|
+
*/
|
|
95
|
+
export declare function sendTg(chatId: string | number, text: string, threadId?: string | number, replyMarkup?: unknown, replyToMessageId?: number | null): Promise<TelegramApiResponse>;
|
|
96
|
+
/**
|
|
97
|
+
* editMessageText with MarkdownV2-first + 429 retry-after handling +
|
|
98
|
+
* plain-text fallback.
|
|
99
|
+
*/
|
|
100
|
+
export declare function editTg(chatId: string | number, messageId: number, text: string, replyMarkup?: unknown): Promise<TelegramApiResponse>;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/lib/telegram-bot-api.ts — v0.25.0 M16 extracted HTTP layer.
|
|
3
|
+
*
|
|
4
|
+
* Pre-M16 the Telegram Bot API helpers lived inside the legacy live-card +
|
|
5
|
+
* card-renderer modules. M16 deletes those modules, but a handful of lib/
|
|
6
|
+
* utilities (error-renderer.ts, perf/speculative-bubble.ts) still need to
|
|
7
|
+
* dispatch Telegram messages. This file is the migrated, slim HTTP layer:
|
|
8
|
+
* • telegramApi(method, params) — generic POST to api.telegram.org
|
|
9
|
+
* • sendTg(chatId, text, ...) — sendMessage with MarkdownV2 + plain
|
|
10
|
+
* text fallback (preserves v0.20.1
|
|
11
|
+
* content-punctuation fix).
|
|
12
|
+
* • editTg(chatId, msgId, text…) — editMessageText with same fallback +
|
|
13
|
+
* 429 retry handling.
|
|
14
|
+
* • BOT_TOKEN exported as a mutable getter (mutated via setBotToken /
|
|
15
|
+
* initBotTokenFromConfig at boot).
|
|
16
|
+
*
|
|
17
|
+
* Token sourcing on boot (initBotTokenFromConfig):
|
|
18
|
+
* 1. api.config.channels.telegram.accounts[defaultAccount].botToken
|
|
19
|
+
* 2. ~/.openclaw/openclaw.json → same JSON path
|
|
20
|
+
* 3. fallthrough: BOT_TOKEN stays '' and renderer/sendTg return false.
|
|
21
|
+
*
|
|
22
|
+
* The mirror channel's register() (M0..M14 + M15-cutover-default) calls
|
|
23
|
+
* initBotTokenFromConfig(api) at boot — the same shape the legacy live-card
|
|
24
|
+
* used to do.
|
|
25
|
+
*/
|
|
26
|
+
import { request as httpsRequest } from 'node:https';
|
|
27
|
+
import { readFileSync } from 'node:fs';
|
|
28
|
+
import { homedir } from 'node:os';
|
|
29
|
+
import { join } from 'node:path';
|
|
30
|
+
export const OPENCLAW_CONFIG_PATH = join(homedir(), '.openclaw', 'openclaw.json');
|
|
31
|
+
const PLUGIN_TAG = '[cc-openclaw/telegram-bot-api]';
|
|
32
|
+
// ─── Bot token state ───────────────────────────────────────────────────────
|
|
33
|
+
let _botToken = '';
|
|
34
|
+
/**
|
|
35
|
+
* Mutable getter for the current bot token. Callers should treat it as
|
|
36
|
+
* read-only at runtime; use setBotToken / initBotTokenFromConfig to mutate.
|
|
37
|
+
*/
|
|
38
|
+
export function getBotToken() {
|
|
39
|
+
return _botToken;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Imperative setter — for tests + explicit init paths. Returns the
|
|
43
|
+
* previous value so test cleanup can restore.
|
|
44
|
+
*/
|
|
45
|
+
export function setBotToken(token) {
|
|
46
|
+
const prev = _botToken;
|
|
47
|
+
_botToken = token;
|
|
48
|
+
return prev;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Back-compat alias — legacy code did `import { BOT_TOKEN } from ...`. We
|
|
52
|
+
* preserve the binding via a frozen wrapper that always reflects the
|
|
53
|
+
* current token. Existing read-sites get the current value; existing
|
|
54
|
+
* write-sites (none expected — legacy only wrote via setBotToken under
|
|
55
|
+
* a different name) would need migration.
|
|
56
|
+
*
|
|
57
|
+
* Using a getter-backed object also lets `if (!BOT_TOKEN)` work
|
|
58
|
+
* idiomatically; the property is read on every access.
|
|
59
|
+
*/
|
|
60
|
+
export const BOT_TOKEN = Object.freeze({
|
|
61
|
+
get value() {
|
|
62
|
+
return _botToken;
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
export function initBotTokenFromConfig(api) {
|
|
66
|
+
const logger = api?.logger;
|
|
67
|
+
// 1. api.config.channels.telegram path
|
|
68
|
+
try {
|
|
69
|
+
const tg = api?.config?.channels?.telegram;
|
|
70
|
+
if (tg?.accounts) {
|
|
71
|
+
const key = tg.defaultAccount ?? 'default';
|
|
72
|
+
const token = tg.accounts[key]?.botToken;
|
|
73
|
+
if (token) {
|
|
74
|
+
_botToken = token;
|
|
75
|
+
logger?.info(`${PLUGIN_TAG} bot token loaded from api.config`);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
/* fall through to file path */
|
|
82
|
+
}
|
|
83
|
+
// 2. ~/.openclaw/openclaw.json
|
|
84
|
+
try {
|
|
85
|
+
const raw = readFileSync(OPENCLAW_CONFIG_PATH, 'utf8');
|
|
86
|
+
const parsed = JSON.parse(raw);
|
|
87
|
+
const tg = parsed.channels?.telegram;
|
|
88
|
+
if (tg?.accounts) {
|
|
89
|
+
const key = tg.defaultAccount ?? 'default';
|
|
90
|
+
const token = tg.accounts[key]?.botToken;
|
|
91
|
+
if (token) {
|
|
92
|
+
_botToken = token;
|
|
93
|
+
logger?.info(`${PLUGIN_TAG} bot token loaded from ${OPENCLAW_CONFIG_PATH}`);
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
logger?.warn(`${PLUGIN_TAG} config-file fallback failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
100
|
+
}
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Low-level POST to api.telegram.org. Resolves with the parsed JSON
|
|
105
|
+
* response, or {ok:false} on JSON parse failure / network error
|
|
106
|
+
* (rejection is the caller's signal for a truly unreachable endpoint).
|
|
107
|
+
*/
|
|
108
|
+
export function telegramApi(method, params) {
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
const body = JSON.stringify(params);
|
|
111
|
+
const options = {
|
|
112
|
+
hostname: 'api.telegram.org',
|
|
113
|
+
path: `/bot${_botToken}/${method}`,
|
|
114
|
+
method: 'POST',
|
|
115
|
+
headers: {
|
|
116
|
+
'Content-Type': 'application/json',
|
|
117
|
+
'Content-Length': Buffer.byteLength(body),
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
const req = httpsRequest(options, (res) => {
|
|
121
|
+
let data = '';
|
|
122
|
+
res.on('data', (chunk) => (data += chunk));
|
|
123
|
+
res.on('end', () => {
|
|
124
|
+
try {
|
|
125
|
+
resolve(JSON.parse(data));
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
resolve({ ok: false, description: 'JSON parse error' });
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
req.on('error', (err) => reject(err));
|
|
133
|
+
req.setTimeout(10_000, () => {
|
|
134
|
+
req.destroy(new Error('Telegram API timeout'));
|
|
135
|
+
});
|
|
136
|
+
req.write(body);
|
|
137
|
+
req.end();
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* sendMessage with MarkdownV2 first + plain-text fallback. The fallback
|
|
142
|
+
* is the v0.20.1 fix: prior implementation stripped punctuation on
|
|
143
|
+
* MarkdownV2 parse errors; current behaviour retries with parse_mode
|
|
144
|
+
* omitted so all content survives.
|
|
145
|
+
*/
|
|
146
|
+
export async function sendTg(chatId, text, threadId, replyMarkup, replyToMessageId) {
|
|
147
|
+
try {
|
|
148
|
+
const base = { chat_id: chatId, disable_web_page_preview: true };
|
|
149
|
+
if (threadId)
|
|
150
|
+
base.message_thread_id = Number(threadId);
|
|
151
|
+
if (replyMarkup)
|
|
152
|
+
base.reply_markup = replyMarkup;
|
|
153
|
+
if (replyToMessageId)
|
|
154
|
+
base.reply_to_message_id = Number(replyToMessageId);
|
|
155
|
+
const res = await telegramApi('sendMessage', { ...base, text, parse_mode: 'MarkdownV2' });
|
|
156
|
+
if (res.ok)
|
|
157
|
+
return res;
|
|
158
|
+
return telegramApi('sendMessage', { ...base, text: text || 'Session update' });
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
return { ok: false };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* editMessageText with MarkdownV2-first + 429 retry-after handling +
|
|
166
|
+
* plain-text fallback.
|
|
167
|
+
*/
|
|
168
|
+
export async function editTg(chatId, messageId, text, replyMarkup) {
|
|
169
|
+
try {
|
|
170
|
+
const params = {
|
|
171
|
+
chat_id: chatId,
|
|
172
|
+
message_id: messageId,
|
|
173
|
+
text,
|
|
174
|
+
parse_mode: 'MarkdownV2',
|
|
175
|
+
disable_web_page_preview: true,
|
|
176
|
+
};
|
|
177
|
+
if (replyMarkup)
|
|
178
|
+
params.reply_markup = replyMarkup;
|
|
179
|
+
const res = await telegramApi('editMessageText', params);
|
|
180
|
+
if (!res.ok && (res.error_code === 429 || res.description?.includes('Too Many Requests'))) {
|
|
181
|
+
const retryAfterSec = res.parameters?.retry_after || 5;
|
|
182
|
+
const waitMs = Math.min(retryAfterSec * 1000, 30_000);
|
|
183
|
+
await new Promise((r) => setTimeout(r, waitMs));
|
|
184
|
+
const retry = await telegramApi('editMessageText', params);
|
|
185
|
+
if (retry.ok)
|
|
186
|
+
return retry;
|
|
187
|
+
}
|
|
188
|
+
if (res.ok)
|
|
189
|
+
return res;
|
|
190
|
+
const fallback = {
|
|
191
|
+
chat_id: chatId,
|
|
192
|
+
message_id: messageId,
|
|
193
|
+
text: text || 'Session update',
|
|
194
|
+
disable_web_page_preview: true,
|
|
195
|
+
};
|
|
196
|
+
if (replyMarkup)
|
|
197
|
+
fallback.reply_markup = replyMarkup;
|
|
198
|
+
return telegramApi('editMessageText', fallback);
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
return { ok: false };
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=telegram-bot-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telegram-bot-api.js","sourceRoot":"","sources":["../../../src/lib/telegram-bot-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC;AAElF,MAAM,UAAU,GAAG,gCAAgC,CAAC;AAEpD,8EAA8E;AAE9E,IAAI,SAAS,GAAG,EAAE,CAAC;AAEnB;;;GAGG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,MAAM,IAAI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