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

Function resolveTargetChat

admin_board/admin_board.ts:337–372  ·  view source on GitHub ↗
(
  msg: Api.Message,
  rawTarget?: string,
)

Source from the content-addressed store, hash-verified

335 throw new Error("当前对话不是群组、超级群或频道");
336 }
337 return toTargetChat(entity);
338 }
339
340 const target = rawTarget.trim();
341 if (!target) throw new Error("目标对话不能为空");
342
343 if (/^-?\d+$/.test(target)) {
344 const entity = await client.getEntity(Number(target));
345 if (!(entity instanceof Api.Chat || entity instanceof Api.Channel)) {
346 throw new Error("目标必须是群组、超级群或频道");
347 }
348 return toTargetChat(entity);
349 }
350
351 if (target.startsWith("@")) {
352 const entity = await client.getEntity(target);
353 if (!(entity instanceof Api.Chat || entity instanceof Api.Channel)) {
354 throw new Error("目标必须是群组、超级群或频道");
355 }
356 return toTargetChat(entity);
357 }
358
359 throw new Error("目标对话仅支持 @username 或 对话 ID");
360}
361
362async function getAdminCollection(
363 target: TargetChat,
364): Promise<AdminCollection> {
365 const client = await getGlobalClient();
366 if (!client) throw new Error("Telegram 客户端未初始化");
367
368 let allAdmins: Api.User[];
369
370 if (target.isChannel) {
371 const users = await client.getParticipants(target.entity, {
372 filter: new Api.ChannelParticipantsAdmins(),
373 showTotal: false,
374 });
375

Callers 4

handleSeatActionFunction · 0.85
handleClearCacheActionFunction · 0.85
handleTrimActionFunction · 0.85
AdminBoardPluginClass · 0.85

Calls 1

toTargetChatFunction · 0.85

Tested by

no test coverage detected