mirror of
https://github.com/bellingcat/telegram-phone-number-checker.git
synced 2026-06-11 12:58:29 +03:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a503856c2 | ||
|
|
d7f5415a4e | ||
|
|
9ed496d690 |
@@ -57,7 +57,7 @@ The result will be written to the console but also written as JSON to a `results
|
||||
|
||||
For each phone number, you can expect the following possible responses:
|
||||
|
||||
1. If available, you will receive the Telegram Username,Name, and ID that are connected with this number.
|
||||
1. If available, you will receive the Telegram Username, Name, and ID that are connected with this number.
|
||||
2. 'no username detected'. This means that it looks like the number was used to create a Telegram account but the user did not choose a Telegram Username. It is optional to create a Username on Telegram.
|
||||
3. 'ERROR: no response, the user does not exist or has blocked contact adding.': There can be several reasons for this response. Either the phone number has not been used to create a Telegram account. Or: The phone number is connected to a Telegram account but the user has restricted the option to find him/her via the phone number.
|
||||
4. Or: another error occurred.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "telegram-phone-number-checker"
|
||||
version = "1.0.2"
|
||||
version = "1.0.5"
|
||||
description = "Check if phone numbers are connected to Telegram accounts."
|
||||
authors = ["Bellingcat"]
|
||||
license = "MIT"
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import os, json
|
||||
from telethon.sync import TelegramClient, errors
|
||||
import os, json, re
|
||||
from telethon.sync import TelegramClient, errors, functions
|
||||
from telethon.tl.types import InputPhoneContact
|
||||
from telethon import functions
|
||||
from dotenv import load_dotenv
|
||||
from dotenv import load_dotenv, dotenv_values, find_dotenv
|
||||
from getpass import getpass
|
||||
import click
|
||||
|
||||
load_dotenv()
|
||||
|
||||
def get_names(client, phone_number):
|
||||
"""
|
||||
This function takes in a phone number and returns the username first name and the last name of the user if the user exists. It does so by first adding the user's phones to the contact list, retrieving the information, and then deleting the user from the contact list.
|
||||
@@ -48,7 +45,7 @@ def validate_users(client, phone_numbers):
|
||||
if not phone_numbers or not len(phone_numbers):
|
||||
phone_numbers = input('Enter the phone numbers to check, separated by commas: ')
|
||||
result = {}
|
||||
phones = [p.strip() for p in phone_numbers.split(",")]
|
||||
phones = [re.sub(r"\s+", "", p, flags=re.UNICODE) for p in phone_numbers.split(",")]
|
||||
try:
|
||||
for phone in phones:
|
||||
if phone not in result:
|
||||
@@ -91,6 +88,7 @@ def show_results(output, res):
|
||||
@click.option('--output', help='results filename, default to results.json', default="results.json", type=str)
|
||||
def main_entrypoint(phone_numbers, api_id, api_hash, api_phone_number, output):
|
||||
"""Check to see if one or more phone numbers belong to a valid Telegram account"""
|
||||
load_dotenv(".env")
|
||||
client = login(api_id, api_hash, api_phone_number)
|
||||
res = validate_users(client, phone_numbers)
|
||||
show_results(output, res)
|
||||
|
||||
Reference in New Issue
Block a user