(token: string, chatId: string, text: string)
| 566 | const btn = this.findCallbackButton(msg, target); |
| 567 | if (!btn) throw new Error(`未找到回调按钮: ${target.callbackData || target.buttonText || target.id}`); |
| 568 | await client.invoke( |
| 569 | new Api.messages.GetBotCallbackAnswer({ |
| 570 | peer, |
| 571 | msgId: msg.id, |
| 572 | data: btn.data || Buffer.from(target.callbackData || "", "utf-8"), |
| 573 | }) |
| 574 | ); |
| 575 | } |
| 576 | |
| 577 | private findCallbackButton(msg: Api.Message, target: SignTarget): any | null { |
| 578 | const rows = (msg as any).replyMarkup?.rows || []; |
| 579 | for (const row of rows) { |
| 580 | for (const b of row.buttons || []) { |
| 581 | const d = this.decodeData(b.data); |
| 582 | if (target.callbackData && d === target.callbackData) return b; |
| 583 | if (!target.callbackData && target.buttonText && b.text === target.buttonText) return b; |
| 584 | } |
| 585 | } |
| 586 | return null; |
| 587 | } |
| 588 | |
| 589 | private parseButtonMatcher(args: string[]): Pick<SignTarget, "callbackData" | "buttonText"> { |
| 590 | const raw = args.join(" ").trim(); |
no test coverage detected