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

Function handleSeatAction

admin_board/admin_board.ts:1246–1345  ·  view source on GitHub ↗
(
  msg: Api.Message,
  action: "lock" | "unlock",
  rawText: string,
)

Source from the content-addressed store, hash-verified

1244 text: `❌ 参数不足\n\n用法:\n<code>${htmlEscape(
1245 commandName,
1246 )} ${action} 用户1,用户2 [对话id/@username]</code>`,
1247 parseMode: "html",
1248 linkPreview: false,
1249 });
1250 return;
1251 }
1252
1253 const target = await resolveTargetChat(msg, targetArg);
1254 await msg.edit({
1255 text: `🔍 正在解析要${action === "lock" ? "锁定" : "取消锁定"}席位的用户...\n${buildTargetDisplay(
1256 target,
1257 )}`,
1258 parseMode: "html",
1259 linkPreview: false,
1260 });
1261
1262 const resolvedUsers = new Map<string, Api.User>();
1263 const rawResolvedIds = new Set<string>();
1264 const failures: string[] = [];
1265
1266 for (const identifier of identifiers) {
1267 try {
1268 const user = await resolveUserForSeatAction(target, identifier);
1269 if (!user) {
1270 if (/^-?\d+$/.test(identifier.trim())) {
1271 rawResolvedIds.add(String(Number(identifier.trim())));
1272 } else {
1273 failures.push(`${identifier}(未找到用户)`);
1274 }
1275 continue;
1276 }
1277 resolvedUsers.set(getUserIdString(user), user);
1278 } catch (error: any) {
1279 if (/^-?\d+$/.test(identifier.trim())) {
1280 rawResolvedIds.add(String(Number(identifier.trim())));
1281 } else {
1282 failures.push(
1283 `${identifier}(${normalizeErrorMessage(error?.message || "解析失败")})`,
1284 );
1285 }
1286 }
1287 }
1288
1289 const resolvedList = Array.from(resolvedUsers.values());
1290 const storedUserIds = Array.from(
1291 new Set([
1292 ...resolvedList.map((user) => getUserIdString(user)),
1293 ...Array.from(rawResolvedIds),
1294 ]),
1295 );
1296
1297 if (storedUserIds.length > 0) {
1298 await updateLockedSeats(target, storedUserIds, action === "lock");
1299 }
1300
1301 const lines = [
1302 `${action === "lock" ? "🔒" : "🔓"} <b>席位${
1303 action === "lock" ? "锁定" : "取消锁定"

Callers 1

AdminBoardPluginClass · 0.85

Calls 15

getTextAfterTokensFunction · 0.85
parseSeatActionArgsFunction · 0.85
resolveTargetChatFunction · 0.85
buildTargetDisplayFunction · 0.85
resolveUserForSeatActionFunction · 0.85
getUserIdStringFunction · 0.85
normalizeErrorMessageFunction · 0.85
updateLockedSeatsFunction · 0.85
buildUserDisplayFunction · 0.85
getCachedUserInfoFunction · 0.85
sendLongResultFunction · 0.85

Tested by

no test coverage detected