This PR extends the help text printed to the console when users enter the --help flag. The help text now includes information on prerequisites (like getting an api id and hash) and storing these in a local .env file. It also adds an epilog command argument to point users to the official repo's README.md.
Other changes:
Click automatically sets the api_id, api_hash, api_phone_number to API_ID, API_HASH, and PHONE_NUMBER environment variables if the user does not specify them. This is already done in login(...) via calls to os.getenv - but by using click we guarantee that the entered value is not None (since click will re-prompt if user doesn't enter text) and we better support CLI users.
Updates the type annotation for login function parameters to indicate they may be None.
Moves load_dotenv() to the top of the file so environment variables load before the main entrypoint runs.
Hide's the user's api_hash when they're entering it for greater security.
Instructs click to show default arguments for options like results.json. This also displays the default environment variable that click uses for id/hash/phone #.
Resolves: #13
Example:
➜ poetry run telegram-phone-number-checker --help
Usage: telegram-phone-number-checker [OPTIONS]
Check to see if one or more phone numbers belong to a valid Telegram
account.
Prerequisites:
1. A Telegram account with an active phone number
2. A Telegram App api_id and App api_hash, which you can get by creating
a Telegram App @ https://my.telegram.org/apps
Note:
If you do not want to enter the API ID, API hash, or phone number associated with
your Telegram account on the command line, you can store these values in a `.env`
file located within the same directory you run this command from.
// .env file example:
API_ID=12345678
API_HASH=1234abcd5678efgh1234abcd567
PHONE_NUMBER=+15555555555
See the official Telegram docs at
https://core.telegram.org/api/obtaining_api_id for more information on
obtaining an API ID.
Recommendations:
Telegram recommends entering phone numbers in international format
+(country code)(city or carrier code)(your number)
i.e. +491234567891
Options:
-p, --phone-numbers TEXT List of phone numbers to check, separated by
commas
--api-id TEXT Your Telegram app api_id [env var: API_ID]
--api-hash TEXT Your Telegram app api_hash [env var: API_HASH]
--api-phone-number TEXT Your phone number [env var: PHONE_NUMBER]
--output TEXT Filename to store results [default: results.json]
--help Show this message and exit.
Check out the docs at github.com/bellingcat/telegram-phone-number-checker
for more information.
This PR extends the help text printed to the console when users enter the
--help
flag. The help text now includes information on prerequisites (like getting an api id and hash) and storing these in a local.env
file. It also adds anepilog
command argument to point users to the official repo'sREADME.md
.Other changes:
api_id
,api_hash
,api_phone_number
toAPI_ID
,API_HASH
, andPHONE_NUMBER
environment variables if the user does not specify them. This is already done inlogin(...)
via calls toos.getenv
- but by usingclick
we guarantee that the entered value is notNone
(since click will re-prompt if user doesn't enter text) and we better support CLI users.login
function parameters to indicate they may beNone
.load_dotenv()
to the top of the file so environment variables load before the main entrypoint runs.api_hash
when they're entering it for greater security.results.json
. This also displays the default environment variable that click uses for id/hash/phone #.Resolves: #13
Example: