(
msg: Api.Message,
question: string,
rawAnswer: string,
replyToId?: number,
token?: AbortToken,
)
| 4498 | |
| 4499 | private async handleLongContentWithTelegraph( |
| 4500 | msg: Api.Message, |
| 4501 | question: string, |
| 4502 | rawAnswer: string, |
| 4503 | replyToId?: number, |
| 4504 | token?: AbortToken, |
| 4505 | ): Promise<void> { |
| 4506 | const configManager = await this.getConfigManager(); |
| 4507 | const config = configManager.getConfig(); |
| 4508 | |
| 4509 | const telegraphMarkdown = `**Q:**\n${question}\n\n**A:**\n${rawAnswer}\n`; |
| 4510 | const telegraphResult = await this.messageUtils.createTelegraphPage( |
| 4511 | telegraphMarkdown, |
| 4512 | question, |
| 4513 | token, |
| 4514 | ); |
| 4515 | |
| 4516 | const poweredByText = `\n<i>🍀Powered by ${config.currentChatTag}</i>`; |
| 4517 | const safeQuestion = htmlEscape(question); |
| 4518 | const questionBlock = config.collapse |
| 4519 | ? `Q:\n<blockquote expandable>${safeQuestion}</blockquote>\n` |
| 4520 | : `Q:\n${safeQuestion}\n`; |
| 4521 | const answerBlock = config.collapse |
| 4522 | ? `A:\n<blockquote expandable>📰内容比较长,Telegraph 观感更好喔:\n🔗 <a href="${telegraphResult.url}">点我阅读内容</a></blockquote>${poweredByText}` |
| 4523 | : `A:\n📰内容比较长,Telegraph 观感更好喔:\n🔗 <a href="${telegraphResult.url}">点我阅读内容</a>${poweredByText}`; |
| 4524 | |
| 4525 | await MessageSender.sendNew( |
| 4526 | msg, |
| 4527 | questionBlock + answerBlock, |
| 4528 | { parseMode: "html", linkPreview: false }, |
| 4529 | replyToId, |
| 4530 | ); |
| 4531 | |
| 4532 | await configManager.updateConfig((cfg) => { |
| 4533 | cfg.telegraph.list.push(telegraphResult); |
| 4534 | if (cfg.telegraph.list.length > cfg.telegraph.limit) |
| 4535 | cfg.telegraph.list.shift(); |
| 4536 | }); |
| 4537 | } |
| 4538 | } |
| 4539 | |
| 4540 | class SearchFeature extends BaseFeatureHandler { |
| 4541 | readonly name = "联网搜索"; |
no test coverage detected