Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
2.0 kB
5
Indexable
Never
from pyrogram import Client
from pyrogram.errors import UserPrivacyRestricted, ChatAdminRequired
import os
import time

# Definisci le informazioni dei client
clients = [
]
num_clients = len(clients)
current_client = 0

for client in clients:
    client.start()

# Avvia lo script e aggiungi i membri al gruppo
def add_members_to_group():
    global current_client
    user_ids = read_user_ids_from_file("users.txt")  # Leggi gli ID degli utenti da un file
    group_id = -1001560931720  # ID del gruppo
    for user_id in user_ids:
        current_client = current_client % num_clients
        session_client = clients[current_client]
        try:
            session_client.send_message(user_id, f"Ciao! Sto provando ad aggiungerti")
            session_client.add_chat_members(group_id, user_id)  # Aggiungi l'utente al gruppo
            print(f"Added user {user_id} from session {current_client+1}")
        except UserPrivacyRestricted:
            # Invia un messaggio all'utente con il nuovo link del gruppo
            try:
                session_client.send_message(user_id, f"Ecco il nuovo link del gruppo: t.me/pandabuycrew")
                print(f"Sent message to user {user_id} from session {current_client+1}")
            except ChatAdminRequired:
                print(f"Cannot send message to user {user_id} from session {current_client+1}: Admin access required")
        except Exception as e:
            print(f"Error adding user {user_id} from session {current_client+1}: {e}")

        current_client += 1
        time.sleep(3)  # Aggiungi uno sleep di 3 secondi tra un'aggiunta e l'altra

    print("Done!")

# Funzione per leggere gli ID degli utenti da un file
def read_user_ids_from_file(file_path):
    with open(file_path, "r") as file:
        lines = file.readlines()
        user_ids = [line.strip() for line in lines if line.strip()]
    return user_ids

# Avvia lo script
if __name__ == "__main__":
    add_members_to_group()