From da7a2db4c4c1ee205f02cde6b90fe0c76a4c14ae Mon Sep 17 00:00:00 2001 From: Logan Williams Date: Fri, 21 May 2021 10:46:56 +0200 Subject: [PATCH] Move phone number to .env file --- .gitignore | 2 ++ README.md | 5 +++-- telegram-phone-validation.py | 8 ++++---- 3 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bd6f3bc --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env +*.session diff --git a/README.md b/README.md index 01de032..bb33b84 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,15 @@ This script lets you check whether a specific phone number is connected to a Tel 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/. Place these values in a .env file: +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, along with the phone number of your Telegram account: ``` API_ID= API_HASH= +PHONE_NUMBER= ``` -Then, run the script: `python3 telegram-phone-validation.py --phone_number +15558675309` +Then, run the script: `python3 telegram-phone-validation.py` You can expect the following possible responses: diff --git a/telegram-phone-validation.py b/telegram-phone-validation.py index cd9b8f5..4f8ca28 100644 --- a/telegram-phone-validation.py +++ b/telegram-phone-validation.py @@ -12,6 +12,7 @@ result = {} API_ID = os.getenv('API_ID') API_HASH = os.getenv('API_HASH') +PHONE_NUMBER = os.getenv('PHONE_NUMBER') def get_names(phone_number): try: @@ -45,14 +46,13 @@ def user_validator(): if __name__ == '__main__': 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 = TelegramClient(PHONE_NUMBER, API_ID, API_HASH) client.connect() if not client.is_user_authorized(): - client.send_code_request(args.phone_number) - client.sign_in(args.phone_number, input('Enter the code (sent on telegram): ')) + client.send_code_request(PHONE_NUMBER) + client.sign_in(PHONE_NUMBER, input('Enter the code (sent on telegram): ')) user_validator() print(result)