Lazy console login

This commit is contained in:
Andrea Cavalli 2021-09-27 21:55:17 +02:00
parent 8949e35bf9
commit c6a8af0c44
2 changed files with 13 additions and 1 deletions

View File

@ -21,6 +21,10 @@ final class ConsoleInteractiveAuthenticationData implements AuthenticationData {
initializeIfNeeded();
}
public boolean isInitialized() {
return initialized;
}
@Override
public boolean isBot() {
initializeIfNeeded();

View File

@ -15,7 +15,15 @@ final class ScannerClientInteraction implements ClientInteraction {
public String onParameterRequest(InputParameter parameter, ParameterInfo parameterInfo) {
AuthenticationData authenticationData = authenticable.getAuthenticationData();
String who;
if (authenticationData.isBot()) {
boolean useRealWho;
if (authenticationData instanceof ConsoleInteractiveAuthenticationData) {
useRealWho = ((ConsoleInteractiveAuthenticationData) authenticationData).isInitialized();
} else {
useRealWho = true;
}
if (!useRealWho) {
who = "login";
} else if (authenticationData.isBot()) {
who = authenticationData.getBotToken().split(":", 2)[0];
} else {
who = "+" + authenticationData.getUserPhoneNumber();