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

Method handleBasicCommand

aban/aban.ts:1135–1234  ·  view source on GitHub ↗
(
    client: TelegramClient,
    message: Api.Message,
    action: 'kick' | 'ban' | 'unban' | 'mute' | 'unmute'
  )

Source from the content-addressed store, hash-verified

1133 return client.invoke(
1134 new Api.messages.DeleteChatUser({
1135 chatId: bigInt(this.getBasicGroupChatId(group.id)),
1136 userId: resolvedParticipant,
1137 })
1138 );
1139 }
1140 const channelInput = await resolveChannelInput(client, group);
1141 return client.invoke(
1142 new Api.channels.EditBanned({
1143 channel: channelInput,
1144 participant: resolvedParticipant,
1145 bannedRights: rights,
1146 })
1147 );
1148 };
1149
1150 // 单组重试:FLOOD_WAIT 等待 ≤ 8s 时重试一次,其余错误直接返回
1151 const attempt = async (retriesLeft: number): Promise<
1152 | { success: true; group: ManagedGroup }
1153 | { success: false; group: ManagedGroup; reason: string }
1154 > => {
1155 try {
1156 await buildRequest();
1157 return { success: true as const, group };
1158 } catch (error) {
1159 const floodSecs = getFloodWaitSeconds(error);
1160 if (floodSecs !== null && floodSecs <= 8 && retriesLeft > 0) {
1161 await sleep((floodSecs + 1) * 1000);
1162 return attempt(retriesLeft - 1);
1163 }
1164 return {
1165 success: false as const,
1166 group,
1167 reason: this.getErrorReason(error),
1168 };
1169 }
1170 };
1171
1172 return attempt(1);
1173 };
1174
1175 const settled = await Promise.allSettled(
1176 groups.map((group) => limit(() => runOne(group)))
1177 );
1178
1179 const results: Array<
1180 | { success: true; group: ManagedGroup }
1181 | { success: false; group: ManagedGroup; reason: string }
1182 > = settled.map((result, index) => {
1183 if (result.status === 'fulfilled') {
1184 return result.value;
1185 }
1186 return {
1187 success: false as const,
1188 group: groups[index],
1189 reason: this.getErrorReason(result.reason),
1190 };
1191 });
1192

Callers 1

AbanPluginClass · 0.80

Calls 14

getActionNameMethod · 0.95
formatDurationMethod · 0.95
isTargetAdminMethod · 0.80
formatUserMethod · 0.80
kickUserMethod · 0.80
banUserMethod · 0.80
unbanUserMethod · 0.80
muteUserMethod · 0.80
htmlEscapeFunction · 0.70
parseTimeStringFunction · 0.70
checkAdminPermissionMethod · 0.45

Tested by

no test coverage detected