| 141 | await msg.edit({ text: helpText }); |
| 142 | } |
| 143 | |
| 144 | private async clearTempFiles(msg: Api.Message) { |
| 145 | try { |
| 146 | const files = fs.readdirSync(this.tempDir); |
| 147 | let deletedCount = 0; |
| 148 | |
| 149 | for (const file of files) { |
| 150 | const filePath = path.join(this.tempDir, file); |
| 151 | try { |
| 152 | fs.unlinkSync(filePath); |
| 153 | deletedCount++; |
| 154 | } catch (e) { |
| 155 | // 忽略删除失败的文件 |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | await msg.edit({ |
| 160 | text: `✅ 已清理 ${deletedCount} 个临时文件。` |
| 161 | }); |
| 162 | } catch (error: any) { |
| 163 | await msg.edit({ |
| 164 | text: `⚠️ 清理临时文件时出错:${error.message}` |
| 165 | }); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | private isValidMedia(msg: Api.Message): boolean { |