foliko 1.0.5 → 1.0.7

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foliko",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "简约的插件化 Agent 框架",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -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
  })
@@ -366,9 +366,12 @@ module.exports = function(Plugin) {
366
366
 
367
367
  const savedMsg = `收到图片${caption ? ': ' + caption : ''}\n已保存至: ${filePath}`
368
368
  await this._sendMessage(chatId, savedMsg, msg.message_id)
369
-
369
+ if(caption){
370
+ const message=`图片:${filePath}, ${caption}`
371
+ await this._processChat(chatId, message, msg.message_id)
372
+ }
370
373
  // TODO: 调用 AI 视觉能力分析图片
371
- // await this._analyzeImage(chatId, filePath, caption)
374
+ // await this._analyzeImage(chatId, filePath, capti on)
372
375
  } catch (err) {
373
376
  console.error('[Telegram] Failed to save photo:', err.message)
374
377
  await this._sendMessage(chatId, '图片保存失败: ' + err.message, msg.message_id)
@@ -399,6 +402,10 @@ module.exports = function(Plugin) {
399
402
 
400
403
  const savedMsg = `收到文件: ${fileName}\n已保存至: ${filePath}${caption ? '\n\n说明: ' + caption : ''}`
401
404
  await this._sendMessage(chatId, savedMsg, msg.message_id)
405
+ if(caption){
406
+ const message=`文件:${filePath}, ${caption}`
407
+ await this._processChat(chatId, message, msg.message_id)
408
+ }
402
409
  } catch (err) {
403
410
  console.error('[Telegram] Failed to save document:', err.message)
404
411
  await this._sendMessage(chatId, '文件保存失败: ' + err.message, msg.message_id)
@@ -435,7 +442,7 @@ module.exports = function(Plugin) {
435
442
  if (savedPath !== finalPath) {
436
443
  fs.renameSync(savedPath, finalPath)
437
444
  }
438
- resolve(finalPath)
445
+ resolve(filePath)
439
446
  })
440
447
  .catch(reject)
441
448
  })