| 1463 | parseMode: "html", |
| 1464 | }); |
| 1465 | return; |
| 1466 | } |
| 1467 | |
| 1468 | const rawText = (msg.message || msg.text || "").trim(); |
| 1469 | const parts = rawText.split(/\s+/); |
| 1470 | const action = (parts[1] || "").toLowerCase(); |
| 1471 | |
| 1472 | if (!action || action === "help" || action === "h") { |
| 1473 | await msg.edit({ |
| 1474 | text: helpText, |
| 1475 | parseMode: "html", |
| 1476 | linkPreview: false, |
| 1477 | }); |
| 1478 | return; |
| 1479 | } |
| 1480 | |
| 1481 | try { |
| 1482 | if (action === "ls") { |
| 1483 | const targetArg = getTextAfterTokens(rawText, 2) || undefined; |
| 1484 | const target = await resolveTargetChat(msg, targetArg); |
| 1485 | const { stats, counts } = await collectAdminStats(msg, target); |
| 1486 | const resultText = buildSortText(target, stats, counts); |
| 1487 | await sendLongResult(msg, resultText); |
| 1488 | return; |
| 1489 | } |
| 1490 | |
| 1491 | if (action === "tail") { |
| 1492 | const remainder = getTextAfterTokens(rawText, 2); |
| 1493 | const firstToken = |
| 1494 | remainder.trim().split(/\s+/).filter(Boolean)[0] || ""; |
| 1495 | if ( |
| 1496 | firstToken && |
| 1497 | /^\d+$/.test(firstToken) && |
| 1498 | !/^[1-9]\d*$/.test(firstToken) |
| 1499 | ) { |
| 1500 | await msg.edit({ |
| 1501 | text: `❌ 参数错误\n\n<code>tail</code> 的人数参数必须是正整数`, |
| 1502 | parseMode: "html", |
| 1503 | linkPreview: false, |
| 1504 | }); |
| 1505 | return; |
| 1506 | } |
| 1507 | |
| 1508 | const { limit, targetArg } = parseTailArgs(remainder); |
| 1509 | const target = await resolveTargetChat(msg, targetArg); |
| 1510 | const { stats, counts } = await collectAdminStats(msg, target); |
| 1511 | const resultText = buildTailText(target, stats, counts, limit); |
| 1512 | await sendLongResult(msg, resultText); |
| 1513 | return; |
| 1514 | } |
| 1515 | |
| 1516 | if (action === "rm") { |
| 1517 | await handleTrimAction(msg, rawText); |
| 1518 | return; |
| 1519 | } |
| 1520 | |
| 1521 | if (action === "lock" || action === "unlock") { |
| 1522 | await handleSeatAction(msg, action, rawText); |
nothing calls this directly
no test coverage detected