Add askAuthData in consoleLogin

This commit is contained in:
Andrea Cavalli 2021-10-24 00:33:57 +02:00
parent e4bda0a3c7
commit 9bfd22b57d
4 changed files with 8 additions and 3 deletions

View File

@ -26,7 +26,7 @@
<dependency>
<groupId>it.tdlight</groupId>
<artifactId>tdlight-java</artifactId>
<version>2.7.8.36</version>
<version>2.7.8.37</version>
</dependency>
<!-- TDLight natives -->

View File

@ -43,7 +43,7 @@ public final class Example {
client = new SimpleTelegramClient(settings);
// Configure the authentication info
var authenticationData = AuthenticationData.consoleLogin();
var authenticationData = AuthenticationData.consoleLogin().askAuthData();
// Add an example update handler that prints when the bot is started
client.addUpdateHandler(TdApi.UpdateAuthorizationState.class, Example::onUpdateAuthorizationState);

View File

@ -22,7 +22,7 @@ public interface AuthenticationData {
return new AuthenticationDataImpl(null, botToken);
}
static AuthenticationData consoleLogin() {
static ConsoleInteractiveAuthenticationData consoleLogin() {
return new ConsoleInteractiveAuthenticationData();
}
}

View File

@ -55,6 +55,11 @@ final class ConsoleInteractiveAuthenticationData implements AuthenticationData {
return botToken;
}
public ConsoleInteractiveAuthenticationData askAuthData() {
initializeIfNeeded();
return this;
}
private void initializeIfNeeded() {
if (initialized) {
return;