Skip to content

Commit b87b1ec

Browse files
authored
Update main.py
1 parent 3c88185 commit b87b1ec

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

main.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,14 @@ async def send_messages():
251251
sent_count = 0
252252
failed_count = 0
253253
removed_users = 0
254+
current_account_index = 0
254255

255-
for index, user in enumerate(users):
256+
for user in users:
256257
if settings['daily_limit'] > 0 and sent_count >= settings['daily_limit']:
257258
break
258259

259-
current_account = active_accounts[index % total_accounts]
260+
# Get the current account to use
261+
current_account = active_accounts[current_account_index]
260262
client = TelegramClient(f'session_{current_account}', API_ID, API_HASH)
261263
await client.connect()
262264

@@ -270,6 +272,10 @@ async def send_messages():
270272
users.remove(user)
271273
removed_users += 1
272274

275+
# Move to next account
276+
current_account_index = (current_account_index + 1) % total_accounts
277+
await client.disconnect()
278+
273279
with open(USERS_FILE, 'w', encoding='utf-8') as f:
274280
f.writelines("\n".join(users))
275281

0 commit comments

Comments
 (0)