@bytesbrains/pi-telegram-bridge 1.1.0 → 1.1.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/package.json +1 -1
- package/src/index.ts +25 -4
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -113,6 +113,7 @@ export default function telegramBridge(pi: ExtensionAPI) {
|
|
|
113
113
|
if (!res.ok)
|
|
114
114
|
return {
|
|
115
115
|
content: [{ type: "text", text: "Could not reach Telegram." }],
|
|
116
|
+
details: { message: "" },
|
|
116
117
|
isError: true,
|
|
117
118
|
};
|
|
118
119
|
|
|
@@ -132,6 +133,7 @@ export default function telegramBridge(pi: ExtensionAPI) {
|
|
|
132
133
|
if (!data.ok)
|
|
133
134
|
return {
|
|
134
135
|
content: [{ type: "text", text: "Telegram API error." }],
|
|
136
|
+
details: { message: "" },
|
|
135
137
|
isError: true,
|
|
136
138
|
};
|
|
137
139
|
|
|
@@ -157,7 +159,10 @@ export default function telegramBridge(pi: ExtensionAPI) {
|
|
|
157
159
|
};
|
|
158
160
|
}
|
|
159
161
|
}
|
|
160
|
-
return {
|
|
162
|
+
return {
|
|
163
|
+
content: [{ type: "text", text: "No new messages." }],
|
|
164
|
+
details: { message: "" },
|
|
165
|
+
};
|
|
161
166
|
} catch (e: unknown) {
|
|
162
167
|
return {
|
|
163
168
|
content: [
|
|
@@ -166,6 +171,7 @@ export default function telegramBridge(pi: ExtensionAPI) {
|
|
|
166
171
|
text: `Failed: ${e instanceof Error ? e.message : e}`,
|
|
167
172
|
},
|
|
168
173
|
],
|
|
174
|
+
details: { message: "" },
|
|
169
175
|
isError: true,
|
|
170
176
|
};
|
|
171
177
|
}
|
|
@@ -181,7 +187,10 @@ export default function telegramBridge(pi: ExtensionAPI) {
|
|
|
181
187
|
async execute(_id: string, params: { message: string }) {
|
|
182
188
|
try {
|
|
183
189
|
const mid = await sendMsg(params.message);
|
|
184
|
-
return {
|
|
190
|
+
return {
|
|
191
|
+
content: [{ type: "text", text: `Sent (id:${mid})` }],
|
|
192
|
+
details: {},
|
|
193
|
+
};
|
|
185
194
|
} catch (e: unknown) {
|
|
186
195
|
return {
|
|
187
196
|
content: [
|
|
@@ -190,6 +199,7 @@ export default function telegramBridge(pi: ExtensionAPI) {
|
|
|
190
199
|
text: `Failed: ${e instanceof Error ? e.message : e}`,
|
|
191
200
|
},
|
|
192
201
|
],
|
|
202
|
+
details: {},
|
|
193
203
|
isError: true,
|
|
194
204
|
};
|
|
195
205
|
}
|
|
@@ -226,12 +236,12 @@ export default function telegramBridge(pi: ExtensionAPI) {
|
|
|
226
236
|
content: [
|
|
227
237
|
{ type: "text", text: "Timeout — proceeding autonomously" },
|
|
228
238
|
],
|
|
229
|
-
details: { timedOut: true },
|
|
239
|
+
details: { timedOut: true, answer: "" },
|
|
230
240
|
};
|
|
231
241
|
}
|
|
232
242
|
return {
|
|
233
243
|
content: [{ type: "text", text: `Reply: "${reply}"` }],
|
|
234
|
-
details: { answer: reply },
|
|
244
|
+
details: { timedOut: false, answer: reply },
|
|
235
245
|
};
|
|
236
246
|
} catch (e: unknown) {
|
|
237
247
|
return {
|
|
@@ -241,6 +251,7 @@ export default function telegramBridge(pi: ExtensionAPI) {
|
|
|
241
251
|
text: `Failed: ${e instanceof Error ? e.message : e}`,
|
|
242
252
|
},
|
|
243
253
|
],
|
|
254
|
+
details: { timedOut: false, answer: "" },
|
|
244
255
|
isError: true,
|
|
245
256
|
};
|
|
246
257
|
}
|
|
@@ -301,6 +312,7 @@ export default function telegramBridge(pi: ExtensionAPI) {
|
|
|
301
312
|
timedOut: true,
|
|
302
313
|
action: "abort",
|
|
303
314
|
command: params.command,
|
|
315
|
+
choice: "",
|
|
304
316
|
},
|
|
305
317
|
};
|
|
306
318
|
}
|
|
@@ -340,6 +352,12 @@ export default function telegramBridge(pi: ExtensionAPI) {
|
|
|
340
352
|
text: `Failed: ${e instanceof Error ? e.message : e}`,
|
|
341
353
|
},
|
|
342
354
|
],
|
|
355
|
+
details: {
|
|
356
|
+
timedOut: false,
|
|
357
|
+
action: "",
|
|
358
|
+
command: "",
|
|
359
|
+
choice: "",
|
|
360
|
+
},
|
|
343
361
|
isError: true,
|
|
344
362
|
};
|
|
345
363
|
}
|
|
@@ -398,6 +416,7 @@ export default function telegramBridge(pi: ExtensionAPI) {
|
|
|
398
416
|
text: "Not configured. Set TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID.",
|
|
399
417
|
},
|
|
400
418
|
],
|
|
419
|
+
details: {},
|
|
401
420
|
};
|
|
402
421
|
}
|
|
403
422
|
try {
|
|
@@ -411,10 +430,12 @@ export default function telegramBridge(pi: ExtensionAPI) {
|
|
|
411
430
|
text: `Active. Bot: @${r.result.username} (listener: ${listenerAbort ? "🟢 running" : "🔴 stopped"})`,
|
|
412
431
|
},
|
|
413
432
|
],
|
|
433
|
+
details: {},
|
|
414
434
|
};
|
|
415
435
|
} catch {
|
|
416
436
|
return {
|
|
417
437
|
content: [{ type: "text", text: "Token set but unreachable." }],
|
|
438
|
+
details: {},
|
|
418
439
|
};
|
|
419
440
|
}
|
|
420
441
|
},
|