(
client: any,
msg: Api.Message,
replied: Api.Message,
isSticker: boolean,
isPhoto: boolean,
)
| 1369 | alt: "📝", |
| 1370 | stickerset: new Api.InputStickerSetEmpty(), |
| 1371 | }), |
| 1372 | ], |
| 1373 | replyTo: replied?.id, |
| 1374 | }); |
| 1375 | |
| 1376 | console.log("[yvlu] 动态贴纸发送成功 (webm)"); |
| 1377 | } finally { |
| 1378 | try { |
| 1379 | fs.unlinkSync(webmPath); |
| 1380 | } catch (e) {} |
| 1381 | } |
| 1382 | } else { |
| 1383 | const file = new CustomFile( |
| 1384 | `quote.${imageExt}`, |
| 1385 | imageBuffer.length, |
| 1386 | "", |
| 1387 | imageBuffer, |
| 1388 | ); |
| 1389 | |
| 1390 | if (imageExt === "webp") { |
| 1391 | const stickerAttr = new Api.DocumentAttributeSticker({ |
| 1392 | alt: "📝", |
| 1393 | stickerset: new Api.InputStickerSetEmpty(), |
| 1394 | }); |
| 1395 | const imageSizeAttr = new Api.DocumentAttributeImageSize({ |
| 1396 | w: dimensions.width, |
| 1397 | h: dimensions.height, |
| 1398 | }); |
| 1399 | const filenameAttr = new Api.DocumentAttributeFilename({ |
| 1400 | fileName: "quote.webp", |
| 1401 | }); |
| 1402 | await client.sendFile(msg.peerId, { |
| 1403 | file, |
| 1404 | forceDocument: false, |
| 1405 | attributes: [stickerAttr, imageSizeAttr, filenameAttr], |
| 1406 | replyTo: replied?.id, |
| 1407 | }); |
| 1408 | console.log("[yvlu] 静态贴纸发送成功"); |
| 1409 | } else { |
| 1410 | await client.sendFile(msg.peerId, { |
| 1411 | file, |
| 1412 | forceDocument: false, |
| 1413 | replyTo: replied?.id, |
| 1414 | }); |
| 1415 | console.log("[yvlu] PNG 图片发送成功"); |
| 1416 | } |
| 1417 | } |
| 1418 | |
| 1419 | console.log("[yvlu] 文件发送成功"); |
| 1420 | } catch (fileError) { |
| 1421 | console.error(`发送文件失败: ${fileError}`); |
| 1422 | await msg.edit({ text: `发送文件失败: ${htmlEscape(String(fileError))}`, parseMode: "html" }); |
| 1423 | return; |
| 1424 | } |
| 1425 | |
| 1426 | await msg.delete(); |
| 1427 | |
| 1428 | const end = Date.now(); |
no test coverage detected