Fix test number

This commit is contained in:
Andrea Cavalli 2023-05-14 23:19:51 +02:00
parent 6a7ba6d412
commit 867d16b91d
3 changed files with 9 additions and 4 deletions

View File

@ -56,7 +56,7 @@ public final class Example {
SimpleTelegramClientBuilder clientBuilder = clientFactory.builder(settings); SimpleTelegramClientBuilder clientBuilder = clientFactory.builder(settings);
// Configure the authentication info // Configure the authentication info
SimpleAuthenticationSupplier<?> authenticationData = AuthenticationSupplier.testUser(3210); // Replace with AuthenticationSupplier.consoleLogin(), or .user(xxx), or .bot(xxx); SimpleAuthenticationSupplier<?> authenticationData = AuthenticationSupplier.testUser(7381); // Replace with AuthenticationSupplier.consoleLogin(), or .user(xxx), or .bot(xxx);
// Add an example update handler that prints when the bot is started // Add an example update handler that prints when the bot is started
clientBuilder.addUpdateHandler(TdApi.UpdateAuthorizationState.class, Example::onUpdateAuthorizationState); clientBuilder.addUpdateHandler(TdApi.UpdateAuthorizationState.class, Example::onUpdateAuthorizationState);

View File

@ -15,7 +15,7 @@ public interface AuthenticationSupplier<T extends AuthenticationData> {
if (value > 9999) { if (value > 9999) {
throw new IllegalArgumentException("value must be lower than 10000"); throw new IllegalArgumentException("value must be lower than 10000");
} }
return new AuthenticationDataImpl("999664" + value, null, true); return new AuthenticationDataImpl("999662" + value, null, true);
} }
CompletableFuture<T> get(); CompletableFuture<T> get();

View File

@ -125,8 +125,13 @@ public final class SimpleTelegramClient implements Authenticable, MutableTelegra
if (!((AuthenticationDataImpl) authenticationData).isBot() if (!((AuthenticationDataImpl) authenticationData).isBot()
&& ((AuthenticationDataImpl) authenticationData).isTest()) { && ((AuthenticationDataImpl) authenticationData).isTest()) {
String phoneNumber = ((AuthenticationDataImpl) authenticationData).getUserPhoneNumber(); String phoneNumber = ((AuthenticationDataImpl) authenticationData).getUserPhoneNumber();
String substring = phoneNumber.substring(5, 6); String loginCodeChar = phoneNumber.substring(5, 6);
return substring + substring + substring + substring; StringBuilder sb = new StringBuilder();
//noinspection StringRepeatCanBeUsed
for (int i = 0; i < 5; i++) {
sb.append(loginCodeChar);
}
return sb.toString();
} }
} }
return null; return null;