| 543 | `; |
| 544 | |
| 545 | class AcronPlugin extends Plugin { |
| 546 | |
| 547 | description: string = `定时发送/转发/复制/置顶/取消置顶/删除消息/执行命令\n\n${help_text}`; |
| 548 | cmdHandlers: Record< |
| 549 | string, |
| 550 | (msg: Api.Message, trigger?: Api.Message) => Promise<void> |
| 551 | > = { |
| 552 | acron: async (msg: Api.Message) => { |
| 553 | const lines = msg.message?.trim()?.split(/\r?\n/g) || []; |
| 554 | |
| 555 | const parts = lines?.[0]?.split(/\s+/) || []; |
| 556 | |
| 557 | const [, ...args] = parts; // 跳过命令本身 |
| 558 | const sub = (args[0] || "").toLowerCase(); |
| 559 | |
| 560 | try { |
| 561 | if (!sub) { |
| 562 | await msg.edit({ |
| 563 | text: help_text, |
| 564 | parseMode: "html", |
| 565 | }); |
| 566 | return; |
| 567 | } |
| 568 | |
| 569 | if (sub === "list" || sub === "ls" || sub === "la") { |
| 570 | let p1 = (args[1] || "").toLowerCase(); |
| 571 | let p2 = (args[2] || "").toLowerCase(); |
| 572 | if (sub === "la") { |
| 573 | p2 = p1; |
| 574 | p1 = "all"; |
| 575 | } |
| 576 | |
| 577 | const scopeAll = p1 === "all"; |
| 578 | const maybeType = (scopeAll ? p2 : p1) as AcronType | ""; |
| 579 | const typeFilter: AcronType | undefined = [ |
| 580 | "send", |
| 581 | "cmd", |
| 582 | "copy", |
| 583 | "forward", |
| 584 | "del", |
| 585 | "del_re", |
| 586 | "pin", |
| 587 | "unpin", |
| 588 | ].includes(maybeType as any) |
| 589 | ? (maybeType as AcronType) |
| 590 | : undefined; |
| 591 | |
| 592 | const typeLabel = (tp?: AcronType) => |
| 593 | tp === "send" |
| 594 | ? "发送" |
| 595 | : tp === "cmd" |
| 596 | ? "命令" |
| 597 | : tp === "copy" |
| 598 | ? "复制" |
| 599 | : tp === "forward" |
| 600 | ? "转发" |
| 601 | : tp === "del" |
| 602 | ? "删除" |
nothing calls this directly
no test coverage detected