From 950da8fa54ca2a644d0258e72075f8ec8aad4f50 Mon Sep 17 00:00:00 2001 From: "Giovanni Solimeno (Crax)" Date: Sun, 21 Jun 2020 13:37:41 +0200 Subject: [PATCH 1/3] Requesting country code when the user forgets it --- tg/config.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tg/config.py b/tg/config.py index 9b4b176..f03a4bc 100644 --- a/tg/config.py +++ b/tg/config.py @@ -77,6 +77,12 @@ else: if not PHONE: PHONE = input("phone> ") + if not PHONE.startswith("+"): + COUNTRY_CODE = input("country code> ") + if not COUNTRY_CODE.startswith("+"): + COUNTRY_CODE = "+" + COUNTRY_CODE + + PHONE = COUNTRY_CODE + PHONE with open(CONFIG_FILE, "w") as f: f.write(f"PHONE = '{PHONE}'\n") From ef6945d0106473107e22fcb2e883dd4a23e60b4a Mon Sep 17 00:00:00 2001 From: "Giovanni Solimeno (Crax)" Date: Mon, 22 Jun 2020 15:33:56 +0200 Subject: [PATCH 2/3] Requesting country code in phone + appending '+' if it's missing --- tg/config.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tg/config.py b/tg/config.py index f03a4bc..1808905 100644 --- a/tg/config.py +++ b/tg/config.py @@ -76,13 +76,10 @@ else: os.makedirs(directory, exist_ok=True) if not PHONE: + print("Enter your phone number in international format (including country code)") PHONE = input("phone> ") if not PHONE.startswith("+"): - COUNTRY_CODE = input("country code> ") - if not COUNTRY_CODE.startswith("+"): - COUNTRY_CODE = "+" + COUNTRY_CODE - - PHONE = COUNTRY_CODE + PHONE + PHONE = "+" + PHONE with open(CONFIG_FILE, "w") as f: f.write(f"PHONE = '{PHONE}'\n") From 3d82ef6cb6886988ac640e57fbccc8f012254198 Mon Sep 17 00:00:00 2001 From: "Giovanni Solimeno (Crax)" Date: Mon, 22 Jun 2020 15:37:19 +0200 Subject: [PATCH 3/3] Formatted according to black --- tg/config.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tg/config.py b/tg/config.py index 1808905..50278b5 100644 --- a/tg/config.py +++ b/tg/config.py @@ -76,7 +76,9 @@ else: os.makedirs(directory, exist_ok=True) if not PHONE: - print("Enter your phone number in international format (including country code)") + print( + "Enter your phone number in international format (including country code)" + ) PHONE = input("phone> ") if not PHONE.startswith("+"): PHONE = "+" + PHONE