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

Function demoteAdminInTarget

admin_board/admin_board.ts:1051–1080  ·  view source on GitHub ↗
(
  target: TargetChat,
  user: Api.User,
)

Source from the content-addressed store, hash-verified

1049 const inputChannel = await client.getInputEntity(target.entity as any);
1050 await client.invoke(
1051 new Api.channels.EditAdmin({
1052 channel: inputChannel as any,
1053 userId: inputUser as any,
1054 adminRights: new Api.ChatAdminRights({}),
1055 rank: "",
1056 }),
1057 );
1058 return;
1059 }
1060
1061 await client.invoke(
1062 new Api.messages.EditChatAdmin({
1063 chatId: (target.entity as any).id,
1064 userId: inputUser as any,
1065 isAdmin: false as any,
1066 }),
1067 );
1068}
1069
1070function isPotentialUserIdentifier(text: string): boolean {
1071 const trimmed = text.trim();
1072 return /^-?\d+$/.test(trimmed) || /^@[A-Za-z0-9_]{3,}$/.test(trimmed);
1073}
1074
1075function parseUserIdentifiers(raw: string): string[] | null {
1076 const parts = raw
1077 .split(/[,,]/g)
1078 .map((part) => part.trim())
1079 .filter((part) => part.length > 0);
1080
1081 if (parts.length === 0) return null;
1082 if (parts.some((part) => !isPotentialUserIdentifier(part))) return null;
1083

Callers 1

handleTrimActionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected