foliko 1.0.5 → 1.0.6
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
CHANGED
|
@@ -15,7 +15,7 @@ const { z } = require('zod')
|
|
|
15
15
|
// 转义 MarkdownV2 特殊字符
|
|
16
16
|
function escapeMarkdown(text) {
|
|
17
17
|
if (!text) return ''
|
|
18
|
-
// MarkdownV2
|
|
18
|
+
// MarkdownV2 需要转义的所有字符
|
|
19
19
|
return text.replace(/([\_*\[\]()~`>#+\-=|{}.!])/g, '\\$1')
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -287,7 +287,7 @@ module.exports = function(Plugin) {
|
|
|
287
287
|
// 定期更新消息
|
|
288
288
|
if (fullResponse.length % 100 === 0) {
|
|
289
289
|
try {
|
|
290
|
-
await this._bot.editMessageText(`📝 ${fullResponse}▌`, {
|
|
290
|
+
await this._bot.editMessageText(`📝 ${escapeMarkdown(fullResponse)}▌`, {
|
|
291
291
|
chat_id: chatId,
|
|
292
292
|
message_id: thinkingMsg.message_id
|
|
293
293
|
})
|
|
@@ -302,7 +302,7 @@ module.exports = function(Plugin) {
|
|
|
302
302
|
session.history.push({ role: 'assistant', content: fullResponse })
|
|
303
303
|
|
|
304
304
|
// 发送最终回复(转义 Markdown 特殊字符)
|
|
305
|
-
const safeResponse = fullResponse || '抱歉,我没有收到有效的回复。'
|
|
305
|
+
const safeResponse = escapeMarkdown(fullResponse) || '抱歉,我没有收到有效的回复。'
|
|
306
306
|
await this._bot.editMessageText(safeResponse, {
|
|
307
307
|
chat_id: chatId,
|
|
308
308
|
message_id: thinkingMsg.message_id,
|
|
@@ -311,7 +311,7 @@ module.exports = function(Plugin) {
|
|
|
311
311
|
|
|
312
312
|
} catch (err) {
|
|
313
313
|
console.error('[Telegram] Chat error:', err)
|
|
314
|
-
await this._bot.editMessageText(`❌ 发生错误:${err.message}
|
|
314
|
+
await this._bot.editMessageText(escapeMarkdown(`❌ 发生错误:${err.message}`), {
|
|
315
315
|
chat_id: chatId,
|
|
316
316
|
message_id: thinkingMsg.message_id
|
|
317
317
|
})
|