MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / showHistory

Method showHistory

whois/whois.ts:557–610  ·  view source on GitHub ↗
(msg: Api.Message)

Source from the content-addressed store, hash-verified

555 output += `<b>失败:</b> ${failCount}\n\n`;
556 output += `<b>查询结果:</b>\n`;
557 output += results.join('\n');
558 output += `\n\n💡 使用 <code>${mainPrefix}whois history</code> 查看详细信息`;
559
560 await msg.edit({
561 text: output,
562 parseMode: "html",
563 linkPreview: false
564 });
565 }
566
567 private async showHistory(msg: Api.Message) {
568 if (!this.db) {
569 await msg.edit({
570 text: "❌ <b>数据库未初始化</b>",
571 parseMode: "html",
572 linkPreview: false
573 });
574 return;
575 }
576
577 const history = this.db.data.history;
578 if (history.length === 0) {
579 await msg.edit({
580 text: `📭 <b>暂无查询历史</b>\n\n💡 使用 <code>${mainPrefix}whois &lt;域名&gt;</code> 开始查询`,
581 parseMode: "html",
582 linkPreview: false
583 });
584 return;
585 }
586
587 let output = `📜 <b>查询历史</b> <i>(最近 ${Math.min(history.length, 20)} 条)</i>\n\n`;
588
589 history.slice(0, 20).forEach((record, index) => {
590 const queryTime = dayjs(record.queryTime);
591 output += `${index + 1}. <code>${htmlEscape(record.domain)}</code>\n`;
592 output += ` <i>${queryTime.format('MM-DD HH:mm')} (${queryTime.fromNow()})</i>\n`;
593
594 if (record.expiryDate) {
595 try {
596 const expiryTime = new Date(record.expiryDate).getTime();
597 const now = Date.now();
598 const daysUntilExpiry = Math.floor((expiryTime - now) / (1000 * 60 * 60 * 24));
599
600 if (daysUntilExpiry < 0) {
601 output += ` ⚠️ <b>已过期</b>\n`;
602 } else if (daysUntilExpiry < 30) {
603 output += ` ⚠️ <b>${daysUntilExpiry} 天后过期</b>\n`;
604 }
605 } catch (e) {
606 // 忽略日期解析错误
607 }
608 }
609 output += `\n`;
610 });
611
612 output += `<b>统计信息:</b>\n`;
613 output += `• 总查询次数:${history.length}\n`;

Callers 1

handleWhoisMethod · 0.95

Calls 2

htmlEscapeFunction · 0.70
editMethod · 0.45

Tested by

no test coverage detected