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

Function resolveTarget

shift/shift.ts:722–744  ·  view source on GitHub ↗
(
  client: TelegramClient,
  targetInput: string,
  currentChatId: number
)

Source from the content-addressed store, hash-verified

720
721 try {
722 const numericId = parseInt(targetInput);
723 if (!isNaN(numericId)) {
724 return await client.getEntity(numericId);
725 }
726 } catch (error) {
727 // Fall through to username
728 }
729
730 return await client.getEntity(targetInput);
731}
732
733async function isCircularForward(
734 sourceId: number,
735 targetId: number
736): Promise<{ isCircular: boolean; message: string }> {
737 if (sourceId === targetId) {
738 return { isCircular: true, message: "不能设置自己到自己的转发规则" };
739 }
740
741 const visited = new Set([sourceId]);
742 let currentId = targetId;
743
744 for (let i = 0; i < 20; i++) {
745 if (visited.has(currentId)) {
746 return { isCircular: true, message: `检测到间接循环:${currentId}` };
747 }

Callers 1

ShiftPluginClass · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected