MCPcopy Index your code
hub / github.com/TeleBoxOrg/TeleBox_Plugins / handleError

Method handleError

clean/clean.ts:489–504  ·  view source on GitHub ↗
(msg: Api.Message, error: any)

Source from the content-addressed store, hash-verified

487 }
488
489 private async handleError(msg: Api.Message, error: any): Promise<void> {
490 console.error(`[CleanPlugin] 错误:`, error);
491
492 let errorMsg = `❌ <b>操作失败:</b> ${htmlEscape(error.message || "未知错误")}`;
493
494 if (error.message?.includes("FLOOD_WAIT")) {
495 const waitTime = parseInt(error.message.match(/\d+/)?.[0] || "60");
496 errorMsg = `⏳ <b>请求过于频繁</b>\n\n需要等待 ${waitTime} 秒后重试`;
497 } else if (error.message?.includes("CHAT_ADMIN_REQUIRED")) {
498 errorMsg = "🔒 <b>权限不足</b>\n\n需要管理员权限";
499 } else if (error.message?.includes("USER_NOT_PARTICIPANT")) {
500 errorMsg = "❌ <b>未加入群组</b>\n\n机器人需要先加入群组";
501 }
502
503 await this.editMessage(msg, errorMsg);
504 }
505
506 private async handleFloodWait(msg: Api.Message, error: any): Promise<void> {
507 const waitTime = parseInt(error.message.match(/\d+/)?.[0] || "60");

Callers 2

handleCleanMethod · 0.95
cleanDeletedPMMethod · 0.95

Calls 3

editMessageMethod · 0.95
errorMethod · 0.80
htmlEscapeFunction · 0.70

Tested by

no test coverage detected