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

Method removeAdmin

manage_admin/manage_admin.ts:349–393  ·  view source on GitHub ↗
(targetArg?: string)

Source from the content-addressed store, hash-verified

347 await msg.edit({ text: "请回复一条消息或提供 用户ID/用户名" });
348 return;
349 }
350 try {
351 const client = await getGlobalClient();
352 if ((msg as any).isChannel) {
353 await client?.invoke(
354 new Api.channels.EditAdmin({
355 channel,
356 userId: userEntity,
357 adminRights: new Api.ChatAdminRights({}),
358 rank: "",
359 })
360 );
361 } else {
362 await client?.invoke(
363 new Api.messages.EditChatAdmin({
364 chatId: (msg as any).chatId,
365 userId: userEntity,
366 isAdmin: false as any,
367 })
368 );
369 }
370 const u = await formatEntity(userId || userEntity, true);
371 await msg.edit({
372 text: `已移除管理员: ${u.display}`,
373 parseMode: "html",
374 });
375 } catch (e: any) {
376 const extra =
377 typeof e?.message === "string" &&
378 e.message.includes("USER_ID_INVALID")
379 ? "\n可能原因:目标不是当前对话中的用户、匿名管理员、或仅提供了数字ID且无法解析。请改为回复该用户的消息或使用 @用户名。"
380 : "";
381 await msg.edit({
382 text: `移除管理员失败:${codeTag(e?.message || e)}${extra}`,
383 parseMode: "html",
384 });
385 }
386 }
387
388 async function listAdmins() {
389 try {
390 const client = await getGlobalClient();
391 if (!(msg as any).isChannel) {
392 await msg.edit({ text: "仅支持超级群/频道列出管理员" });
393 return;
394 }
395 const result = await client?.invoke(
396 new Api.channels.GetParticipants({

Callers

nothing calls this directly

Calls 3

formatEntityFunction · 0.70
codeTagFunction · 0.70
editMethod · 0.45

Tested by

no test coverage detected