diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..548a91e --- /dev/null +++ b/Pipfile @@ -0,0 +1,13 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +telethon = "*" +python-dotenv = "*" + +[dev-packages] + +[requires] +python_version = "3.9" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..039bb40 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,69 @@ +{ + "_meta": { + "hash": { + "sha256": "0c8df074fc457e527734bfb860a87923e5f8f806319557e83d22cbfb7ceea9c4" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.9" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "pyaes": { + "hashes": [ + "sha256:02c1b1405c38d3c370b085fb952dd8bea3fadcee6411ad99f312cc129c536d8f" + ], + "version": "==1.6.1" + }, + "pyasn1": { + "hashes": [ + "sha256:014c0e9976956a08139dc0712ae195324a75e142284d5f87f1a87ee1b068a359", + "sha256:03840c999ba71680a131cfaee6fab142e1ed9bbd9c693e285cc6aca0d555e576", + "sha256:0458773cfe65b153891ac249bcf1b5f8f320b7c2ce462151f8fa74de8934becf", + "sha256:08c3c53b75eaa48d71cf8c710312316392ed40899cb34710d092e96745a358b7", + "sha256:39c7e2ec30515947ff4e87fb6f456dfc6e84857d34be479c9d4a4ba4bf46aa5d", + "sha256:5c9414dcfede6e441f7e8f81b43b34e834731003427e5b09e4e00e3172a10f00", + "sha256:6e7545f1a61025a4e58bb336952c5061697da694db1cae97b116e9c46abcf7c8", + "sha256:78fa6da68ed2727915c4767bb386ab32cdba863caa7dbe473eaae45f9959da86", + "sha256:7ab8a544af125fb704feadb008c99a88805126fb525280b2270bb25cc1d78a12", + "sha256:99fcc3c8d804d1bc6d9a099921e39d827026409a58f2a720dcdb89374ea0c776", + "sha256:aef77c9fb94a3ac588e87841208bdec464471d9871bd5050a287cc9a475cd0ba", + "sha256:e89bf84b5437b532b0803ba5c9a5e054d21fec423a89952a74f87fa2c9b7bce2", + "sha256:fec3e9d8e36808a28efb59b489e4528c10ad0f480e57dcc32b4de5c9d8c9fdf3" + ], + "version": "==0.4.8" + }, + "python-dotenv": { + "hashes": [ + "sha256:00aa34e92d992e9f8383730816359647f358f4a3be1ba45e5a5cefd27ee91544", + "sha256:b1ae5e9643d5ed987fc57cc2583021e38db531946518130777734f9589b3141f" + ], + "index": "pypi", + "version": "==0.17.1" + }, + "rsa": { + "hashes": [ + "sha256:78f9a9bf4e7be0c5ded4583326e7461e3a3c5aae24073648b4bdfa797d78c9d2", + "sha256:9d689e6ca1b3038bc82bf8d23e944b6b6037bc02301a574935b2dd946e0353b9" + ], + "markers": "python_version >= '3.5' and python_version < '4'", + "version": "==4.7.2" + }, + "telethon": { + "hashes": [ + "sha256:993c837ef745addf972a27d7bfba0ce518a2863d1a50e0737255b764d23e0ef2", + "sha256:df643fc988708ad16d16de834ffa12ad4bfa3f956473d835c8158e2283b885ea" + ], + "index": "pypi", + "version": "==1.21.1" + } + }, + "develop": {} +} diff --git a/README.md b/README.md index 34c0ea3..b0ef06b 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,19 @@ -# Telegram_phone_numbers +# telegram-phone-number-checker This script lets you check whether a specific phone number is connected to a Telegram account. To run it, you need: 1. A Telegram account with an active phone number; -2. Telegram 'API_ID' and 'API_HASH', which you can get by creating a developers account using this link: https://my.telegram.org/. +2. Telegram 'API_ID' and 'API_HASH', which you can get by creating a developers account using this link: https://my.telegram.org/. Place these values in a .env file: -Insert your PHONE_NUMBER, the API_ID and the API_HASH in the script. -Then, run the script: python3 Telegram_phone_validation.py +```API_ID= +API_HASH=``` + +Then, run the script: `python3 telegram-phone-validation.py --phone_number +15558675309` You can expect the following possible responses: 1. If available, you will receive the Telegram Username that is connected with this number. 2. 'Response detected, but no user name returned by the API for the number: {phone_number}'. 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: there was no response for the phone number: {phone_number}': 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. Or: another error occurred. - - - diff --git a/Telegram_phone_validation.py b/telegram-phone-validation.py similarity index 70% rename from Telegram_phone_validation.py rename to telegram-phone-validation.py index 79f4765..cd9b8f5 100644 --- a/Telegram_phone_validation.py +++ b/telegram-phone-validation.py @@ -2,12 +2,16 @@ from telethon import TelegramClient, events, sync from telethon.tl.types import InputPhoneContact from telethon import functions, types +from dotenv import load_dotenv +import argparse +import os + +load_dotenv() result = {} -PHONE_NUMBER = # Enter the telegram account phone number here -API_ID = # Enter the api id -API_HASH = #Enter the api hash +API_ID = os.getenv('API_ID') +API_HASH = os.getenv('API_HASH') def get_names(phone_number): try: @@ -40,10 +44,15 @@ def user_validator(): if __name__ == '__main__': - client = TelegramClient(PHONE_NUMBER, API_ID, API_HASH) + parser = argparse.ArgumentParser(description='Check to see if a phone number is a valid Telegram account') + parser.add_argument('--phone_number', dest='phone_number', action='store', help='Enter the phone number to check') + + args = parser.parse_args() + + client = TelegramClient(args.phone_number, API_ID, API_HASH) client.connect() if not client.is_user_authorized(): - client.send_code_request(PHONE_NUMBER) - client.sign_in(PHONE_NUMBER, input('Enter the code (sent on telegram): ')) + client.send_code_request(args.phone_number) + client.sign_in(args.phone_number, input('Enter the code (sent on telegram): ')) user_validator() print(result)