From bcc5321cee05774c7cb088aa550ac559a13d4314 Mon Sep 17 00:00:00 2001 From: teidesu Date: Sat, 17 Apr 2021 19:00:46 +0300 Subject: [PATCH] refactor(client): use _saveStorage instead of storage.save --- packages/client/src/client.ts | 9 +++++++++ packages/client/src/methods/auth/check-password.ts | 2 +- packages/client/src/methods/auth/log-out.ts | 2 +- packages/client/src/methods/auth/recover-password.ts | 1 + packages/client/src/methods/auth/sign-in-bot.ts | 2 +- packages/client/src/methods/auth/sign-in.ts | 2 +- packages/client/src/methods/auth/sign-up.ts | 1 + 7 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/client/src/client.ts b/packages/client/src/client.ts index 27230e2c..c607c237 100644 --- a/packages/client/src/client.ts +++ b/packages/client/src/client.ts @@ -301,6 +301,15 @@ export class TelegramClient extends BaseTelegramClient { * Last name of the user (used only for sign-up, defaults to empty) */ lastName?: MaybeDynamic + + /** + * By using this method to sign up an account, you are agreeing to Telegram + * ToS. This is required and your account will be banned otherwise. + * See https://telegram.org/tos and https://core.telegram.org/api/terms. + * + * If true, TOS will not be displayed and `tosCallback` will not be called. + */ + acceptTos?: boolean }): Promise { return startTest.apply(this, arguments) } diff --git a/packages/client/src/methods/auth/check-password.ts b/packages/client/src/methods/auth/check-password.ts index 1bf6bd2e..2eeb01c5 100644 --- a/packages/client/src/methods/auth/check-password.ts +++ b/packages/client/src/methods/auth/check-password.ts @@ -41,7 +41,7 @@ export async function checkPassword( userId: res.user.id, isBot: false, }) - await this.storage.save?.() + await this._saveStorage() return new User(this, res.user) } diff --git a/packages/client/src/methods/auth/log-out.ts b/packages/client/src/methods/auth/log-out.ts index 99ad77db..6f592737 100644 --- a/packages/client/src/methods/auth/log-out.ts +++ b/packages/client/src/methods/auth/log-out.ts @@ -18,7 +18,7 @@ export async function logOut( if (resetSession) { this.storage.reset() - await this.storage.save?.() + await this._saveStorage() } return true diff --git a/packages/client/src/methods/auth/recover-password.ts b/packages/client/src/methods/auth/recover-password.ts index 5b73b338..3c780079 100644 --- a/packages/client/src/methods/auth/recover-password.ts +++ b/packages/client/src/methods/auth/recover-password.ts @@ -34,6 +34,7 @@ export async function recoverPassword( userId: res.user.id, isBot: false, }) + await this._saveStorage() return new User(this, res.user) } diff --git a/packages/client/src/methods/auth/sign-in-bot.ts b/packages/client/src/methods/auth/sign-in-bot.ts index 0ce53812..57e3f198 100644 --- a/packages/client/src/methods/auth/sign-in-bot.ts +++ b/packages/client/src/methods/auth/sign-in-bot.ts @@ -37,7 +37,7 @@ export async function signInBot( userId: res.user.id, isBot: true, }) - await this.storage.save?.() + await this._saveStorage() return new User(this, res.user) } diff --git a/packages/client/src/methods/auth/sign-in.ts b/packages/client/src/methods/auth/sign-in.ts index 0421d794..e84e46b3 100644 --- a/packages/client/src/methods/auth/sign-in.ts +++ b/packages/client/src/methods/auth/sign-in.ts @@ -45,7 +45,7 @@ export async function signIn( userId: res.user.id, isBot: false, }) - await this.storage.save?.() + await this._saveStorage() return new User(this, res.user) } diff --git a/packages/client/src/methods/auth/sign-up.ts b/packages/client/src/methods/auth/sign-up.ts index f61eea5a..226ef88a 100644 --- a/packages/client/src/methods/auth/sign-up.ts +++ b/packages/client/src/methods/auth/sign-up.ts @@ -36,6 +36,7 @@ export async function signUp( userId: res.user.id, isBot: false, }) + await this._saveStorage() return new User(this, res.user) }