how to get telegram id using phone number

190 views Asked by At

i have a list of my coustomer phone numbers , how should i get the id's for a long list (15,000) in fastest way posible

i tryed older methode's but none of them working any more and some of them not fast enough i need something fast and safe .

one the method i tryed

for number in numbers:
            phone =await conv_number(phone_number=number)
            time.sleep(5.09)

            await app.add_contact(phone_number=str(number) , first_name="" )
                
1

There are 1 answers

0
Mario Locatelli On

I suggest to create a class and than filter it:

class ID():
"""    """

def __init__(self):
    self.ID = 0
    self.name = "name"
    self.phone = "+39 55778895"

Then I populate the list in order to test the efficiency of the function:

# Create list
numbers = []
for i in range(0, 15000):
    numbers.append(ID())
    numbers[i].ID = i
    numbers[i].name = f"name_{i}"
    numbers[i].phone = f"+39 55778895_{i}"

and finallay, filter:

# Filtering
numberToSearch = "+39 55778895_14999"
filtResult = list(filter(lambda x: x.phone == numberToSearch, numbers))

# Result (better to check if object with index 0 exist)
if not filtResult:
    print("Number not found")
else:
    print(filtResult[0].ID)
    print(filtResult[0].name)
    print(filtResult[0].phone)