backup
This commit is contained in:
@@ -4,11 +4,15 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class HandlerWriter {
|
public class HandlerWriter {
|
||||||
|
|
||||||
public static void write(String body) throws IOException {
|
public static void write(String body) throws IOException {
|
||||||
|
|
||||||
|
Consumer<String> consumer = (String s) -> {};
|
||||||
|
|
||||||
String classFilePath = "models/Handlers.class"; // Путь к вашему файлу
|
String classFilePath = "models/Handlers.class"; // Путь к вашему файлу
|
||||||
Path path = Paths.get(classFilePath);
|
Path path = Paths.get(classFilePath);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
package hdvtdev.telegram.core;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
public record InvokeMethod(Method method, Class<?> parameterType) {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package hdvtdev.telegram.core;
|
|
||||||
|
|
||||||
import hdvtdev.telegram.core.objects.Update;
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface UpdateExecutor {
|
|
||||||
|
|
||||||
void execute(Update update);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -12,11 +12,9 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation platform('com.fasterxml.jackson:jackson-bom:2.18.3')
|
implementation platform('com.fasterxml.jackson:jackson-bom:2.18.3')
|
||||||
|
|
||||||
|
|
||||||
implementation 'com.fasterxml.jackson.core:jackson-core'
|
implementation 'com.fasterxml.jackson.core:jackson-core'
|
||||||
implementation 'com.fasterxml.jackson.core:jackson-databind'
|
implementation 'com.fasterxml.jackson.core:jackson-databind'
|
||||||
|
|
||||||
//implementation 'com.squareup.okhttp3:okhttp:4.12.0'
|
|
||||||
implementation 'com.squareup.okhttp3:okhttp:5.2.1'
|
implementation 'com.squareup.okhttp3:okhttp:5.2.1'
|
||||||
implementation(project(":core"))
|
implementation(project(":core"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import hdvtdev.telegram.core.HandlersModule;
|
import hdvtdev.telegram.core.HandlersModule;
|
||||||
import hdvtdev.telegram.core.TelegramBot;
|
import hdvtdev.telegram.core.TelegramBot;
|
||||||
import hdvtdev.telegram.core.UpdateConsumer;
|
import hdvtdev.telegram.core.UpdateConsumer;
|
||||||
import hdvtdev.telegram.core.UpdateExecutor;
|
|
||||||
import hdvtdev.telegram.core.exceptions.TelegramApiException;
|
import hdvtdev.telegram.core.exceptions.TelegramApiException;
|
||||||
import hdvtdev.telegram.core.exceptions.TelegramApiNetworkException;
|
import hdvtdev.telegram.core.exceptions.TelegramApiNetworkException;
|
||||||
import hdvtdev.telegram.core.exceptions.TelegramMethodParsingException;
|
import hdvtdev.telegram.core.exceptions.TelegramMethodParsingException;
|
||||||
@@ -28,6 +27,7 @@ import java.nio.file.StandardCopyOption;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
|
||||||
public class OkHttpTelegramBot implements TelegramBot {
|
public class OkHttpTelegramBot implements TelegramBot {
|
||||||
@@ -38,7 +38,7 @@ public class OkHttpTelegramBot implements TelegramBot {
|
|||||||
|
|
||||||
private ScheduledExecutorService scheduler;
|
private ScheduledExecutorService scheduler;
|
||||||
|
|
||||||
private final UpdateExecutor updateExecutor;
|
private final Consumer<Update> updateExecutor;
|
||||||
private final AtomicLong lastUpdateId = new AtomicLong(0);
|
private final AtomicLong lastUpdateId = new AtomicLong(0);
|
||||||
private int updateLimit = 10;
|
private int updateLimit = 10;
|
||||||
private int updateTimeout = 25;
|
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)));
|
List<Update> updates = List.of(awaitExecute(new GetUpdates(lastUpdateId.get() + 1, updateLimit, updateTimeout)));
|
||||||
if (!updates.isEmpty()) {
|
if (!updates.isEmpty()) {
|
||||||
for (Update update : updates) {
|
for (Update update : updates) {
|
||||||
updateExecutor.execute(update);
|
updateExecutor.accept(update);
|
||||||
}
|
}
|
||||||
lastUpdateId.set(updates.getLast().updateId());
|
lastUpdateId.set(updates.getLast().updateId());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user