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

Method checkBanPermission

clean/clean.ts:599–640  ·  view source on GitHub ↗
(client: any, chatId: any)

Source from the content-addressed store, hash-verified

597${skipped > 0 ? `• 跳过原因: ${includeAll ? '系统限制' : '机器人/诈骗/虚假账户'}` : ''}
598
599💡 <b>提示:</b> ${failed > 0 ? '部分失败可能是由于API限制或网络问题' : '所有操作已成功完成'}`;
600 }
601
602 private async checkBanPermission(client: any, chatId: any): Promise<boolean> {
603 try {
604 const me = await safeGetMe(client);
605 if (!me) return false;
606
607 let participant;
608 if (chatId instanceof Api.Channel) {
609 participant = await client.invoke(new Api.channels.GetParticipant({ channel: chatId, participant: me }));
610 } else {
611 participant = await client.invoke(new Api.messages.GetFullChat({ chatId }));
612 }
613
614 if (participant instanceof Api.channels.ChannelParticipant) {
615 const participantObj = participant.participant;
616 if (participantObj instanceof Api.ChannelParticipantCreator) return true;
617 if (participantObj instanceof Api.ChannelParticipantAdmin) return participantObj.adminRights.banUsers || false;
618 }
619
620 if (participant instanceof Api.messages.ChatFull) {
621 const fullChat = participant.fullChat;
622 if (fullChat instanceof Api.ChatFull) {
623 const participants = fullChat.participants;
624 if (participants instanceof Api.ChatParticipants) {
625 const meParticipant = participants.participants.find((p: any) => p.userId?.equals(me.id));
626 if (meParticipant instanceof Api.ChatParticipantCreator || meParticipant instanceof Api.ChatParticipantAdmin) {
627 return true;
628 }
629 }
630 }
631 }
632
633 return false;
634
635 } catch (error: any) {
636 if (error.message?.includes("CHAT_ADMIN_REQUIRED") ||
637 error.message?.includes("USER_NOT_PARTICIPANT") ||
638 error.message?.includes("PEER_ID_INVALID")) {
639 return false;
640 }
641 return true;
642 }
643 }

Callers 1

cleanDeletedMemberMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected