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

Method handleBatchQuery

whois/whois.ts:458–555  ·  view source on GitHub ↗
(msg: Api.Message, domains: string[])

Source from the content-addressed store, hash-verified

456 await msg.edit({
457 text: formattedOutput,
458 parseMode: "html",
459 linkPreview: false
460 });
461 }
462
463 private async handleBatchQuery(msg: Api.Message, domains: string[]) {
464 if (domains.length === 0) {
465 await msg.edit({
466 text: `❌ <b>请提供要查询的域名</b>\n\n💡 使用示例:<code>${mainPrefix}whois batch google.com github.com</code>`,
467 parseMode: "html",
468 linkPreview: false
469 });
470 return;
471 }
472
473 if (domains.length > 10) {
474 await msg.edit({
475 text: `❌ <b>批量查询限制</b>\n\n每次最多查询 10 个域名,您提供了 ${domains.length} 个`,
476 parseMode: "html",
477 linkPreview: false
478 });
479 return;
480 }
481
482 await msg.edit({
483 text: `🔍 <b>批量查询中...</b>\n\n<b>域名数量:</b> ${domains.length}`,
484 parseMode: "html",
485 linkPreview: false
486 });
487
488 const results: string[] = [];
489 let successCount = 0;
490 let failCount = 0;
491
492 for (let i = 0; i < domains.length; i++) {
493 const domain = domains[i].replace(/^https?:\/\//i, '').replace(/^www\./i, '').split('/')[0];
494
495 // 更新进度
496 await msg.edit({
497 text: `🔍 <b>批量查询中...</b>\n\n<b>进度:</b> ${i + 1}/${domains.length}\n<b>当前域名:</b> <code>${htmlEscape(domain)}</code>`,
498 parseMode: "html",
499 linkPreview: false
500 });
501
502 try {
503 // 检查缓存
504 const cachedResult = await this.getCachedResult(domain);
505 if (cachedResult) {
506 results.push(`✅ <code>${htmlEscape(domain)}</code> - <i>缓存</i>`);
507 successCount++;
508 continue;
509 }
510
511 // 查询域名
512 const batchResponse = await axios.get<string>(`https://namebeta.com/api/search/check`, {
513 params: { query: domain },
514 timeout: 10000,
515 headers: { 'User-Agent': 'TeleBox/1.0' },

Callers 1

handleWhoisMethod · 0.95

Calls 5

getCachedResultMethod · 0.95
saveWhoisRecordMethod · 0.95
extractWhoisFromSSEFunction · 0.85
htmlEscapeFunction · 0.70
editMethod · 0.45

Tested by

no test coverage detected