Move phone number to .env file

This commit is contained in:
Logan Williams
2021-05-21 10:46:56 +02:00
parent 8eef32ff69
commit da7a2db4c4
3 changed files with 9 additions and 6 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.env
*.session

View File

@@ -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:

View File

@@ -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)