mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2026-04-06 06:53:47 +00:00
added BotAuthIfNeeded
This commit is contained in:
parent
53ee143a1d
commit
166a35f732
2 changed files with 13 additions and 1 deletions
|
|
@ -621,6 +621,18 @@ namespace WTelegram
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<User> BotAuthIfNeeded()
|
||||
{
|
||||
if (_session.User != null)
|
||||
return Schema.Deserialize<User>(_session.User);
|
||||
var authorization = await Auth_ImportBotAuthorization(0, _apiId, _apiHash, Config("bot_token"));
|
||||
if (authorization is not Auth_Authorization { user: User user })
|
||||
throw new ApplicationException("Failed to get Authorization: " + authorization.GetType().Name);
|
||||
_session.User = user.Serialize();
|
||||
_session.Save();
|
||||
return user;
|
||||
}
|
||||
|
||||
public async Task<User> UserAuthIfNeeded(CodeSettings settings = null)
|
||||
{
|
||||
if (_session.User != null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue