(originalMsg: Api.Message, stickerFile: string)
| 317 | ]); |
| 318 | } |
| 319 | |
| 320 | private async sendAsSticker(originalMsg: Api.Message, stickerFile: string): Promise<void> { |
| 321 | try { |
| 322 | // 读取文件统计信息 |
| 323 | const stats = fs.statSync(stickerFile); |
| 324 | |
| 325 | // 使用正确的贴纸属性发送 |
| 326 | await this.client.sendFile(originalMsg.chatId!, { |
| 327 | file: stickerFile, |
| 328 | attributes: [ |
| 329 | new Api.DocumentAttributeVideo({ |
| 330 | duration: this.config.maxDuration, |
| 331 | w: this.config.maxWidth, |
| 332 | h: this.config.maxHeight, |
| 333 | supportsStreaming: false, |
| 334 | roundMessage: false |
| 335 | }), |
| 336 | new Api.DocumentAttributeAnimated(), |
| 337 | new Api.DocumentAttributeSticker({ |
| 338 | alt: this.getRandomEmoji(), |
| 339 | stickerset: new Api.InputStickerSetEmpty() |
| 340 | }) |
| 341 | ], |
| 342 | mimeType: "video/webm", |
| 343 | forceDocument: false, |
| 344 | asSticker: true, // 关键:作为贴纸发送 |
| 345 | caption: undefined // 贴纸不需要标题 |
| 346 | }); |
| 347 | |
| 348 | } catch (error: any) { |
| 349 | throw new Error(`发送贴纸失败: ${error.message}`); |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | private async autoAddToStickerPack(originalMsg: Api.Message, stickerFile: string, statusMsg: Api.Message): Promise<void> { |
no test coverage detected