Compare commits

...

1 Commits

Author SHA1 Message Date
hdvt
a9742134b2 backup 2025-11-13 23:51:01 +03:00
5 changed files with 7 additions and 22 deletions

View File

@@ -4,11 +4,15 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.function.Consumer;
import java.util.function.Supplier;
public class HandlerWriter {
public static void write(String body) throws IOException {
Consumer<String> consumer = (String s) -> {};
String classFilePath = "models/Handlers.class"; // Путь к вашему файлу
Path path = Paths.get(classFilePath);

View File

@@ -1,7 +0,0 @@
package hdvtdev.telegram.core;
import java.lang.reflect.Method;
public record InvokeMethod(Method method, Class<?> parameterType) {
}

View File

@@ -1,10 +0,0 @@
package hdvtdev.telegram.core;
import hdvtdev.telegram.core.objects.Update;
@FunctionalInterface
public interface UpdateExecutor {
void execute(Update update);
}

View File

@@ -12,11 +12,9 @@ repositories {
dependencies {
implementation platform('com.fasterxml.jackson:jackson-bom:2.18.3')
implementation 'com.fasterxml.jackson.core:jackson-core'
implementation 'com.fasterxml.jackson.core:jackson-databind'
//implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'com.squareup.okhttp3:okhttp:5.2.1'
implementation(project(":core"))
}

View File

@@ -7,7 +7,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import hdvtdev.telegram.core.HandlersModule;
import hdvtdev.telegram.core.TelegramBot;
import hdvtdev.telegram.core.UpdateConsumer;
import hdvtdev.telegram.core.UpdateExecutor;
import hdvtdev.telegram.core.exceptions.TelegramApiException;
import hdvtdev.telegram.core.exceptions.TelegramApiNetworkException;
import hdvtdev.telegram.core.exceptions.TelegramMethodParsingException;
@@ -28,6 +27,7 @@ import java.nio.file.StandardCopyOption;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer;
public class OkHttpTelegramBot implements TelegramBot {
@@ -38,7 +38,7 @@ public class OkHttpTelegramBot implements TelegramBot {
private ScheduledExecutorService scheduler;
private final UpdateExecutor updateExecutor;
private final Consumer<Update> updateExecutor;
private final AtomicLong lastUpdateId = new AtomicLong(0);
private int updateLimit = 10;
private int updateTimeout = 25;
@@ -153,7 +153,7 @@ public class OkHttpTelegramBot implements TelegramBot {
List<Update> updates = List.of(awaitExecute(new GetUpdates(lastUpdateId.get() + 1, updateLimit, updateTimeout)));
if (!updates.isEmpty()) {
for (Update update : updates) {
updateExecutor.execute(update);
updateExecutor.accept(update);
}
lastUpdateId.set(updates.getLast().updateId());
}