try:
entity = InputUser(int(member["id"]), int(member["access_hash"]))
print("Entity acquired successfully")
print(entity)
target_entity = await temp_client.get_entity(int(f'{-100}{target_group_id}'))
result = await temp_client(InviteToChannelRequest(target_entity, [entity]))
if hasattr(result, 'updates') and len(result.updates) > 0:
print(f'✅ Successfully added {member["id"]}')
added_count += 1
await asyncio.sleep(random.uniform(0.4, 2))
elif hasattr(result, 'users') and len(result.users) > 0:
print(f'✅ Successfully added {member["id"]}')
added_count += 1
await asyncio.sleep(1)
else:
print(f'⚠️ Request accepted but user {member["id"]} was not added (Privacy settings)')
except UserAlreadyParticipantError:
print(f"ℹ️ User {member['id']} is already a participant (Skipped and won't be counted).")
continue
except FloodWaitError as e:
print(f"🚫 Account {account['phone']} got a FloodWait for {e.seconds} seconds. (Account parked)")
flooded_accounts[account['phone']] = time.time() + e.seconds + 60
# ⬅️ This break exits the current batch and moves directly to the next account in the for loop
break
except PeerFloodError:
print("🚫 Global Telegram Flood limit reached. (Account will be temporarily parked).")
flooded_accounts[account['phone']] = time.time() + 300
break
except UserPrivacyRestrictedError:
print(f"🔒 User {member['id']} has restricted invites (Privacy).")
except UserBotError:
print("Bots cannot perform this action. Please use a user account.")
except Exception as e:
print(f"⚠️ Failed to add {member['id']}: {e}")