Compare commits
3 Commits
9fdfd91e1d
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9742134b2 | ||
|
|
a8b772a5ea | ||
|
|
ca295b66f9 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -41,3 +41,7 @@ bin/
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
/core/src/main/java/hdvtdev/telegram/Count.java
|
||||
/src/
|
||||
/test/
|
||||
/.idea/
|
||||
/gradle/
|
||||
|
||||
4
.idea/gradle.xml
generated
4
.idea/gradle.xml
generated
@@ -8,8 +8,12 @@
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/annotation-processor" />
|
||||
<option value="$PROJECT_DIR$/core" />
|
||||
<option value="$PROJECT_DIR$/event-handlers" />
|
||||
<option value="$PROJECT_DIR$/event-handlers-annotations" />
|
||||
<option value="$PROJECT_DIR$/longpolling-okhttp" />
|
||||
<option value="$PROJECT_DIR$/test" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
|
||||
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@@ -1,4 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
|
||||
@@ -49,7 +49,7 @@ public class MyAwesomeBot {
|
||||
}
|
||||
}
|
||||
}
|
||||
});!
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class MyAwesomeBot {
|
||||
}
|
||||
}
|
||||
}
|
||||
});!
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 {
|
||||
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"))
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user