Add askAuthData in consoleLogin
This commit is contained in:
parent
e4bda0a3c7
commit
9bfd22b57d
|
@ -26,7 +26,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>it.tdlight</groupId>
|
<groupId>it.tdlight</groupId>
|
||||||
<artifactId>tdlight-java</artifactId>
|
<artifactId>tdlight-java</artifactId>
|
||||||
<version>2.7.8.36</version>
|
<version>2.7.8.37</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- TDLight natives -->
|
<!-- TDLight natives -->
|
||||||
|
|
|
@ -43,7 +43,7 @@ public final class Example {
|
||||||
client = new SimpleTelegramClient(settings);
|
client = new SimpleTelegramClient(settings);
|
||||||
|
|
||||||
// Configure the authentication info
|
// 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
|
// Add an example update handler that prints when the bot is started
|
||||||
client.addUpdateHandler(TdApi.UpdateAuthorizationState.class, Example::onUpdateAuthorizationState);
|
client.addUpdateHandler(TdApi.UpdateAuthorizationState.class, Example::onUpdateAuthorizationState);
|
||||||
|
|
|
@ -22,7 +22,7 @@ public interface AuthenticationData {
|
||||||
return new AuthenticationDataImpl(null, botToken);
|
return new AuthenticationDataImpl(null, botToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
static AuthenticationData consoleLogin() {
|
static ConsoleInteractiveAuthenticationData consoleLogin() {
|
||||||
return new ConsoleInteractiveAuthenticationData();
|
return new ConsoleInteractiveAuthenticationData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,11 @@ final class ConsoleInteractiveAuthenticationData implements AuthenticationData {
|
||||||
return botToken;
|
return botToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConsoleInteractiveAuthenticationData askAuthData() {
|
||||||
|
initializeIfNeeded();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
private void initializeIfNeeded() {
|
private void initializeIfNeeded() {
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue