mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2025-12-06 06:52:01 +01:00
added BotAuthIfNeeded
This commit is contained in:
parent
53ee143a1d
commit
166a35f732
2
.github/ci.yml
vendored
2
.github/ci.yml
vendored
|
|
@ -2,7 +2,7 @@ pr: none
|
|||
trigger:
|
||||
- master
|
||||
|
||||
name: 0.9.3-ci.$(Rev:r)
|
||||
name: 0.9.4-ci.$(Rev:r)
|
||||
|
||||
pool:
|
||||
vmImage: ubuntu-latest
|
||||
|
|
|
|||
|
|
@ -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…
Reference in a new issue