diff --git a/.github/ci.yml b/.github/ci.yml index cec7554..8073539 100644 --- a/.github/ci.yml +++ b/.github/ci.yml @@ -2,7 +2,7 @@ pr: none trigger: - master -name: 0.9.5-ci.$(Rev:r) +name: 0.9.6-ci.$(Rev:r) pool: vmImage: ubuntu-latest diff --git a/README.md b/README.md index 7a4c447..af3885a 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ If the verification succeeds but the phone number is unknown to Telegram, the us And that's it, you now have access to the [full range of Telegram services](https://core.telegram.org/methods), mainly through calls to `await client.Some_TL_Method(...)` # Saved session -If you run this program again, you will notice that the previous prompts are gone and you are automatically logged-on and ready to go. +If you run this program again, you will notice that only **api_id** and **api_hash** are requested, the other prompts are gone and you are automatically logged-on and ready to go. This is because WTelegramClient saves (typically in the encrypted file **bin\WTelegram.session**) its state and the authentication keys that were negociated with Telegram so that you needn't sign-in again every time. diff --git a/src/Client.cs b/src/Client.cs index 45d6471..534a9f0 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -70,6 +70,7 @@ namespace WTelegram "system_lang_code" => CultureInfo.InstalledUICulture.TwoLetterISOLanguageName, "lang_pack" => "", "lang_code" => CultureInfo.CurrentUICulture.TwoLetterISOLanguageName, + "user_id" => "-1", _ => null // api_id api_hash phone_number verification_code... it's up to you to reply to these correctly }; @@ -676,7 +677,7 @@ namespace WTelegram /// /// Login as a user (if not already done). /// Config callback is queried for: phone_number, verification_code - ///
and eventually first_name, last_name (signup required), password (2FA auth) + ///
and eventually first_name, last_name (signup required), password (2FA auth), user_id (alt validation) ///
/// /// Detail about the logged user @@ -689,7 +690,7 @@ namespace WTelegram { var prevUser = Schema.Deserialize(_session.User); var userId = _config("user_id"); // if config prefers to validate current user by its id, use it - if (userId != null && int.TryParse(userId, out int id) && prevUser.id == id) + if (userId != null && int.TryParse(userId, out int id) && (id == -1 || prevUser.id == id)) return prevUser; phone_number = Config("phone_number"); // otherwise, validation is done by the phone number if (prevUser?.phone == string.Concat(phone_number.Where(char.IsDigit)))