orchestrix-yuri 4.0.0 → 4.0.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/lib/gateway/channels/telegram.js +22 -4
- package/lib/gateway/index.js +12 -4
- package/package.json +1 -1
|
@@ -47,10 +47,28 @@ class TelegramAdapter {
|
|
|
47
47
|
const chunks = splitMessage(reply.text, 4000);
|
|
48
48
|
|
|
49
49
|
if (placeholder && chunks.length === 1) {
|
|
50
|
-
// Single chunk: edit
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
// Single chunk: try to edit placeholder in-place
|
|
51
|
+
let edited = false;
|
|
52
|
+
try {
|
|
53
|
+
await ctx.api.editMessageText(ctx.chat.id, placeholder.message_id, chunks[0], { parse_mode: 'Markdown' });
|
|
54
|
+
edited = true;
|
|
55
|
+
} catch {
|
|
56
|
+
// Markdown parse failed — try without parse_mode
|
|
57
|
+
try {
|
|
58
|
+
await ctx.api.editMessageText(ctx.chat.id, placeholder.message_id, chunks[0]);
|
|
59
|
+
edited = true;
|
|
60
|
+
} catch (editErr) {
|
|
61
|
+
log.warn(`Edit failed: ${editErr.message}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Edit failed entirely — delete placeholder and send as new message
|
|
66
|
+
if (!edited) {
|
|
67
|
+
await ctx.api.deleteMessage(ctx.chat.id, placeholder.message_id).catch(() => {});
|
|
68
|
+
await ctx.reply(chunks[0], { parse_mode: 'Markdown' }).catch(() => {
|
|
69
|
+
return ctx.reply(chunks[0]);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
54
72
|
} else {
|
|
55
73
|
// Multi-chunk: delete placeholder, send chunks separately
|
|
56
74
|
if (placeholder) {
|
package/lib/gateway/index.js
CHANGED
|
@@ -31,7 +31,10 @@ async function startGateway(opts = {}) {
|
|
|
31
31
|
// Track active adapters for graceful shutdown
|
|
32
32
|
const adapters = [];
|
|
33
33
|
|
|
34
|
-
// Start Telegram adapter if
|
|
34
|
+
// Start Telegram adapter if token present (auto-enable)
|
|
35
|
+
if (config.channels.telegram.token) {
|
|
36
|
+
config.channels.telegram.enabled = true;
|
|
37
|
+
}
|
|
35
38
|
if (config.channels.telegram.enabled && config.channels.telegram.token) {
|
|
36
39
|
const telegram = new TelegramAdapter({
|
|
37
40
|
token: config.channels.telegram.token,
|
|
@@ -65,8 +68,12 @@ async function startGateway(opts = {}) {
|
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
70
|
|
|
68
|
-
// Start Feishu adapter if
|
|
69
|
-
|
|
71
|
+
// Start Feishu adapter if credentials present (auto-enable)
|
|
72
|
+
const feishuHasCreds = config.channels.feishu.app_id && config.channels.feishu.app_secret;
|
|
73
|
+
if (feishuHasCreds) {
|
|
74
|
+
config.channels.feishu.enabled = true;
|
|
75
|
+
}
|
|
76
|
+
if (config.channels.feishu.enabled && feishuHasCreds) {
|
|
70
77
|
const { FeishuAdapter } = require('./channels/feishu');
|
|
71
78
|
const feishu = new FeishuAdapter({
|
|
72
79
|
appId: config.channels.feishu.app_id,
|
|
@@ -86,7 +93,8 @@ async function startGateway(opts = {}) {
|
|
|
86
93
|
await feishu.start();
|
|
87
94
|
} catch (err) {
|
|
88
95
|
log.error(`Feishu failed to start: ${err.message}`);
|
|
89
|
-
|
|
96
|
+
log.info('Telegram will continue running. Fix Feishu config and restart.');
|
|
97
|
+
// Don't exit — let Telegram continue if it's also running
|
|
90
98
|
}
|
|
91
99
|
}
|
|
92
100
|
|