mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2025-12-06 06:52:01 +01:00
Updated README about 2nd run prompts.
Validation of logged-in user can be skipped with user_id = -1 (use it cautiously, if you're sure you're not changing user between sessions)
This commit is contained in:
parent
832e2143f5
commit
c5e9e228a7
2
.github/ci.yml
vendored
2
.github/ci.yml
vendored
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
|||
/// <summary>
|
||||
/// Login as a user (if not already done).
|
||||
/// Config callback is queried for: phone_number, verification_code
|
||||
/// <br/>and eventually first_name, last_name (signup required), password (2FA auth)
|
||||
/// <br/>and eventually first_name, last_name (signup required), password (2FA auth), user_id (alt validation)
|
||||
/// </summary>
|
||||
/// <param name="settings"></param>
|
||||
/// <returns>Detail about the logged user</returns>
|
||||
|
|
@ -689,7 +690,7 @@ namespace WTelegram
|
|||
{
|
||||
var prevUser = Schema.Deserialize<User>(_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)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue