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

Function handleTrimAction

admin_board/admin_board.ts:1374–1463  ·  view source on GitHub ↗
(
  msg: Api.Message,
  rawText: string,
)

Source from the content-addressed store, hash-verified

1372 commandName,
1373 )} rm 正整数 [对话id/@username]</code>`,
1374 parseMode: "html",
1375 linkPreview: false,
1376 });
1377 return;
1378 }
1379
1380 const target = await resolveTargetChat(msg, targetArg);
1381 const { stats, counts } = await collectAdminStats(msg, target);
1382 const candidates = stats.filter(
1383 (stat) => !stat.lockedSeat && !isCreatorUser(stat.user),
1384 );
1385 const selected = candidates.slice(-limit).reverse();
1386
1387 if (selected.length === 0) {
1388 await msg.edit({
1389 text: [
1390 `✂️ <b>无需处理</b>`,
1391 buildTargetDisplay(target),
1392 `说明: <code>没有可下掉的未锁定席位管理员</code>`,
1393 ].join("\n"),
1394 parseMode: "html",
1395 linkPreview: false,
1396 });
1397 return;
1398 }
1399
1400 const successLines: string[] = [];
1401 const failureLines: string[] = [];
1402
1403 for (let index = 0; index < selected.length; index++) {
1404 const stat = selected[index];
1405 await msg.edit({
1406 text: `✂️ 正在下掉倒数管理员...\n${buildTargetDisplay(
1407 target,
1408 )}\n进度: <code>${index + 1}/${selected.length}</code>`,
1409 parseMode: "html",
1410 linkPreview: false,
1411 });
1412
1413 try {
1414 await demoteAdminInTarget(target, stat.user);
1415 successLines.push(
1416 `• ${buildUserDisplay(stat.user)} | <code>${htmlEscape(
1417 stat.avgPerDayText,
1418 )}</code>`,
1419 );
1420 } catch (error: any) {
1421 failureLines.push(
1422 `• ${buildUserDisplay(stat.user)}(${htmlEscape(
1423 normalizeErrorMessage(error?.message || "执行失败"),
1424 )})`,
1425 );
1426 }
1427 }
1428
1429 const lines = [
1430 `✂️ <b>尾部管理员清理完成</b>`,
1431 buildTargetDisplay(target),

Callers 1

AdminBoardPluginClass · 0.85

Calls 12

getTextAfterTokensFunction · 0.85
parseTrimArgsFunction · 0.85
resolveTargetChatFunction · 0.85
collectAdminStatsFunction · 0.85
isCreatorUserFunction · 0.85
buildTargetDisplayFunction · 0.85
demoteAdminInTargetFunction · 0.85
buildUserDisplayFunction · 0.85
normalizeErrorMessageFunction · 0.85
sendLongResultFunction · 0.85
htmlEscapeFunction · 0.70
editMethod · 0.45

Tested by

no test coverage detected