From 40ddcbca6062f13958f4ca2c9852f8d1c4d62f3c Mon Sep 17 00:00:00 2001 From: Gor <47748749+ke1io@users.noreply.github.com> Date: Tue, 20 Feb 2024 02:27:00 +0400 Subject: [PATCH] Add system_lang_code to Client and missing enums to SentCodeType (#27) --- pyrogram/client.py | 7 +++++++ pyrogram/enums/sent_code_type.py | 6 ++++++ pyrogram/session/session.py | 2 +- pyrogram/storage/file_storage.py | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pyrogram/client.py b/pyrogram/client.py index 956b4499..ef1c099e 100644 --- a/pyrogram/client.py +++ b/pyrogram/client.py @@ -96,6 +96,10 @@ class Client(Methods): Code of the language used on the client, in ISO 639-1 standard. Defaults to "en". + system_lang_code (``str``, *optional*): + Code of the language used on the system, in ISO 639-1 standard. + Defaults to "en". + ipv6 (``bool``, *optional*): Pass True to connect to Telegram using IPv6. Defaults to False (IPv4). @@ -193,6 +197,7 @@ class Client(Methods): LANG_PACK = "" LANG_CODE = "en" + SYSTEM_LANG_CODE = "en" PARENT_DIR = Path(sys.argv[0]).parent @@ -218,6 +223,7 @@ class Client(Methods): system_version: str = SYSTEM_VERSION, lang_pack: str = LANG_PACK, lang_code: str = LANG_CODE, + system_lang_code: str = SYSTEM_LANG_CODE, ipv6: bool = False, proxy: dict = None, test_mode: bool = False, @@ -248,6 +254,7 @@ class Client(Methods): self.system_version = system_version self.lang_pack = lang_pack.lower() self.lang_code = lang_code.lower() + self.system_lang_code = system_lang_code.lower() self.ipv6 = ipv6 self.proxy = proxy self.test_mode = test_mode diff --git a/pyrogram/enums/sent_code_type.py b/pyrogram/enums/sent_code_type.py index 474ed6b0..a2c252d6 100644 --- a/pyrogram/enums/sent_code_type.py +++ b/pyrogram/enums/sent_code_type.py @@ -43,3 +43,9 @@ class SentCodeType(AutoName): EMAIL_CODE = raw.types.auth.SentCodeTypeEmailCode "The code was sent via email." + + FIREBASE_SMS = raw.types.auth.SentCodeTypeFirebaseSms + "The code should be delivered via SMS after Firebase attestation." + + SETUP_EMAIL_REQUIRED = raw.types.auth.SentCodeTypeSetUpEmailRequired + "The user should add and verify an email address in order to login." diff --git a/pyrogram/session/session.py b/pyrogram/session/session.py index e5b53d17..b2a93d2f 100644 --- a/pyrogram/session/session.py +++ b/pyrogram/session/session.py @@ -125,7 +125,7 @@ class Session: app_version=self.client.app_version, device_model=self.client.device_model, system_version=self.client.system_version, - system_lang_code=self.client.lang_code, + system_lang_code=self.client.system_lang_code, lang_pack=self.client.lang_pack, lang_code=self.client.lang_code, query=raw.functions.help.GetConfig(), diff --git a/pyrogram/storage/file_storage.py b/pyrogram/storage/file_storage.py index 1c77688c..628a1131 100644 --- a/pyrogram/storage/file_storage.py +++ b/pyrogram/storage/file_storage.py @@ -26,7 +26,7 @@ from .sqlite_storage import SQLiteStorage log = logging.getLogger(__name__) SCHEMA = """ -CREATE TABLE usernames +CREATE TABLE IF NOT EXISTS usernames ( id INTEGER, username TEXT,