2
.gitignore
vendored
2
.gitignore
vendored
@@ -40,4 +40,4 @@ bin/
|
|||||||
|
|
||||||
### Mac OS ###
|
### Mac OS ###
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/src/main/java/hdvtdev/telegram/Count.java
|
/core/src/main/java/hdvtdev/telegram/Count.java
|
||||||
|
|||||||
2
.idea/gradle.xml
generated
2
.idea/gradle.xml
generated
@@ -8,6 +8,8 @@
|
|||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/core" />
|
||||||
|
<option value="$PROJECT_DIR$/longpolling-okhttp" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
|
|||||||
136
TODO/ClassFinder.java
Normal file
136
TODO/ClassFinder.java
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.annotations.handlers.CallbackQueryHandler;
|
||||||
|
import hdvtdev.telegram.annotations.handlers.TextMessageHandler;
|
||||||
|
import hdvtdev.telegram.objects.CallbackQuery;
|
||||||
|
import hdvtdev.telegram.objects.Message;
|
||||||
|
import hdvtdev.telegram.objects.Update;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.security.CodeSource;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.jar.JarEntry;
|
||||||
|
import java.util.jar.JarFile;
|
||||||
|
|
||||||
|
public abstract class ClassFinder {
|
||||||
|
|
||||||
|
private static final Set<Class<? extends Annotation>> annotationsToSearch = Set.of(TextMessageHandler.class, CallbackQueryHandler.class);
|
||||||
|
private static final Set<Class<?>> methodsArgumentType = Set.of(Message.class, Update.class, CallbackQuery.class);
|
||||||
|
|
||||||
|
private static ErrorHandler errorHandler;
|
||||||
|
|
||||||
|
public static Map<Class<?>, Map<String, InvokeMethod>> getClasses() {
|
||||||
|
|
||||||
|
Map<Class<?>, Map<String, InvokeMethod>> allMethods = new HashMap<>();
|
||||||
|
annotationsToSearch.forEach(annotation -> allMethods.put(annotation, new HashMap<>()));
|
||||||
|
|
||||||
|
CodeSource codeSource = ClassFinder.class.getProtectionDomain().getCodeSource();
|
||||||
|
if (codeSource != null) {
|
||||||
|
try {
|
||||||
|
String path = codeSource.getLocation().toURI().getPath();
|
||||||
|
File file = new File(URLDecoder.decode(path, StandardCharsets.UTF_8));
|
||||||
|
|
||||||
|
if (file.isFile() && file.getName().endsWith(".jar")) {
|
||||||
|
processJar(file, allMethods);
|
||||||
|
} else if (file.isDirectory()) {
|
||||||
|
processDirectory(file, "", allMethods);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return Map.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Collections.unmodifiableMap(allMethods);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void processDirectory(File directory, String packageName, Map<Class<?>, Map<String, InvokeMethod>> methods) {
|
||||||
|
File[] files = directory.listFiles();
|
||||||
|
if (files == null) return;
|
||||||
|
|
||||||
|
for (File file : files) {
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
processDirectory(file, packageName + file.getName() + ".", methods);
|
||||||
|
} else if (file.getName().endsWith(".class")) {
|
||||||
|
|
||||||
|
String className = packageName + file.getName().replace(".class", "");
|
||||||
|
loadClass(className, methods);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void processJar(File jarFile, Map<Class<?>, Map<String, InvokeMethod>> methods) {
|
||||||
|
try (JarFile jar = new JarFile(jarFile)) {
|
||||||
|
Enumeration<JarEntry> entries = jar.entries();
|
||||||
|
while (entries.hasMoreElements()) {
|
||||||
|
JarEntry entry = entries.nextElement();
|
||||||
|
if (entry.getName().endsWith(".class")) {
|
||||||
|
String className = entry.getName()
|
||||||
|
.replace("/", ".")
|
||||||
|
.replace(".class", "");
|
||||||
|
|
||||||
|
loadClass(className, methods);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<Class<?>, Map<String, InvokeMethod>> localScan(Class<?> cls) {
|
||||||
|
Map<Class<?>, Map<String, InvokeMethod>> allMethods = new HashMap<>();
|
||||||
|
annotationsToSearch.forEach(annotation -> allMethods.put(annotation, new HashMap<>()));
|
||||||
|
loadClass(cls.getName(), allMethods);
|
||||||
|
return allMethods;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void loadClass(String className, Map<Class<?>, Map<String, InvokeMethod>> methods) {
|
||||||
|
try {
|
||||||
|
Class<?> c = Class.forName(className);
|
||||||
|
|
||||||
|
for (Method method : c.getDeclaredMethods()) {
|
||||||
|
|
||||||
|
Class<?>[] parameters = method.getParameterTypes();
|
||||||
|
|
||||||
|
if (parameters.length != 0 && !methodsArgumentType.contains(parameters[0])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method.isAnnotationPresent(CallbackQueryHandler.class)) {
|
||||||
|
if (Modifier.isStatic(method.getModifiers())) {
|
||||||
|
for (String value : method.getAnnotation(CallbackQueryHandler.class).value()) {
|
||||||
|
methods.get(CallbackQueryHandler.class).put(value, new InvokeMethod(method, parameters[0]));
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
System.err.println(method + " is annotated with @CallbackQueryHandler, but it is not static. For the annotation to work, the method must be static.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method.isAnnotationPresent(TextMessageHandler.class)) {
|
||||||
|
if (Modifier.isStatic(method.getModifiers())) {
|
||||||
|
for (String value : method.getAnnotation(TextMessageHandler.class).value()) {
|
||||||
|
methods.get(TextMessageHandler.class).put(value, new InvokeMethod(method, parameters[0]));
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
System.err.println(method + " is annotated with @TextMessageHandler, but it is not static. For the annotation to work, the method must be static.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (NoClassDefFoundError | UnsupportedClassVersionError | ClassNotFoundException e) {
|
||||||
|
if (errorHandler != null) errorHandler.onError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorHandler(ErrorHandler errorHandler) {
|
||||||
|
ClassFinder.errorHandler = errorHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ErrorHandler {
|
||||||
|
void onError(Throwable throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
19
build.gradle
19
build.gradle
@@ -10,18 +10,17 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.3'
|
implementation(project(":core"))
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
|
implementation(project(":longpolling-okhttp"))
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
tasks.register('fat', Jar) {
|
||||||
|
archiveClassifier.set('all')
|
||||||
manifest {
|
|
||||||
attributes(
|
|
||||||
'Main-Class': 'hdvtdev.telegram.Main'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
from sourceSets.main.output
|
||||||
|
|
||||||
|
from {
|
||||||
|
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
16
core/build.gradle
Normal file
16
core/build.gradle
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
plugins {
|
||||||
|
id 'java'
|
||||||
|
}
|
||||||
|
|
||||||
|
group = 'com.github.hdvtdev'
|
||||||
|
version = '1.0.0'
|
||||||
|
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.3'
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package hdvtdev.telegram.core;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
public record InvokeMethod(Method method, Class<?> parameterType) {
|
||||||
|
|
||||||
|
}
|
||||||
57
core/src/main/java/hdvtdev/telegram/core/TelegramBot.java
Normal file
57
core/src/main/java/hdvtdev/telegram/core/TelegramBot.java
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package hdvtdev.telegram.core;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.exceptions.TelegramApiException;
|
||||||
|
import hdvtdev.telegram.core.exceptions.TelegramApiNetworkException;
|
||||||
|
import hdvtdev.telegram.core.exceptions.TelegramMethodParsingException;
|
||||||
|
import hdvtdev.telegram.core.methods.TelegramApiMethod;
|
||||||
|
import hdvtdev.telegram.core.objects.media.TelegramFile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
public interface TelegramBot {
|
||||||
|
|
||||||
|
<T> T awaitExecute(TelegramApiMethod<T> telegramApiMethod) throws TelegramApiException, TelegramApiNetworkException, TelegramMethodParsingException;
|
||||||
|
|
||||||
|
File awaitDownloadFile(TelegramFile telegramFile, Path targetDirectory);
|
||||||
|
|
||||||
|
void shutdown();
|
||||||
|
|
||||||
|
default CompletableFuture<File> downloadFile(TelegramFile telegramFile, Path targetDirectory) {
|
||||||
|
CompletableFuture<File> completableFuture = CompletableFuture.supplyAsync(() -> awaitDownloadFile(telegramFile, targetDirectory));
|
||||||
|
completableFuture.exceptionally(e -> {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
return completableFuture;
|
||||||
|
}
|
||||||
|
|
||||||
|
default <T> CompletableFuture<T> execute(TelegramApiMethod<T> telegramApiMethod) {
|
||||||
|
CompletableFuture<T> completableFuture = CompletableFuture.supplyAsync(() -> awaitExecute(telegramApiMethod));
|
||||||
|
completableFuture.exceptionally(e -> {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
return completableFuture;
|
||||||
|
}
|
||||||
|
|
||||||
|
default int getPing() throws TelegramApiNetworkException {
|
||||||
|
URI uri = URI.create("https://api.telegram.org");
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
try {
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
|
||||||
|
connection.setRequestMethod("GET");
|
||||||
|
connection.setConnectTimeout(15000);
|
||||||
|
connection.connect();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new TelegramApiNetworkException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int) (System.currentTimeMillis() - startTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
32
core/src/main/java/hdvtdev/telegram/core/UpdateConsumer.java
Normal file
32
core/src/main/java/hdvtdev/telegram/core/UpdateConsumer.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package hdvtdev.telegram.core;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.objects.ChosenInlineResult;
|
||||||
|
import hdvtdev.telegram.core.objects.InlineQuery;
|
||||||
|
import hdvtdev.telegram.core.objects.Update;
|
||||||
|
import hdvtdev.telegram.core.objects.business.BusinessConnection;
|
||||||
|
import hdvtdev.telegram.core.objects.business.BusinessMessagesDeleted;
|
||||||
|
import hdvtdev.telegram.core.objects.callback.CallbackQuery;
|
||||||
|
import hdvtdev.telegram.core.objects.chat.ChatJoinRequest;
|
||||||
|
import hdvtdev.telegram.core.objects.chat.ChatMemberUpdated;
|
||||||
|
import hdvtdev.telegram.core.objects.chatboost.ChatBoostRemoved;
|
||||||
|
import hdvtdev.telegram.core.objects.chatboost.ChatBoostUpdated;
|
||||||
|
import hdvtdev.telegram.core.objects.media.paidmedia.PaidMediaPurchased;
|
||||||
|
import hdvtdev.telegram.core.objects.message.Message;
|
||||||
|
import hdvtdev.telegram.core.objects.message.MessageReactionCountUpdated;
|
||||||
|
import hdvtdev.telegram.core.objects.message.MessageReactionUpdated;
|
||||||
|
import hdvtdev.telegram.core.objects.payment.PreCheckoutQuery;
|
||||||
|
import hdvtdev.telegram.core.objects.payment.ShippingQuery;
|
||||||
|
import hdvtdev.telegram.core.objects.poll.Poll;
|
||||||
|
import hdvtdev.telegram.core.objects.poll.PollAnswer;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface UpdateConsumer {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void onUpdates(List<Update> updates);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
80
core/src/main/java/hdvtdev/telegram/core/UpdateHandler.java
Normal file
80
core/src/main/java/hdvtdev/telegram/core/UpdateHandler.java
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
package hdvtdev.telegram.core;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.objects.ChosenInlineResult;
|
||||||
|
import hdvtdev.telegram.core.objects.InlineQuery;
|
||||||
|
import hdvtdev.telegram.core.objects.Update;
|
||||||
|
import hdvtdev.telegram.core.objects.business.BusinessConnection;
|
||||||
|
import hdvtdev.telegram.core.objects.business.BusinessMessagesDeleted;
|
||||||
|
import hdvtdev.telegram.core.objects.callback.CallbackQuery;
|
||||||
|
import hdvtdev.telegram.core.objects.chat.ChatJoinRequest;
|
||||||
|
import hdvtdev.telegram.core.objects.chat.ChatMemberUpdated;
|
||||||
|
import hdvtdev.telegram.core.objects.chatboost.ChatBoostRemoved;
|
||||||
|
import hdvtdev.telegram.core.objects.chatboost.ChatBoostUpdated;
|
||||||
|
import hdvtdev.telegram.core.objects.media.paidmedia.PaidMediaPurchased;
|
||||||
|
import hdvtdev.telegram.core.objects.message.Message;
|
||||||
|
import hdvtdev.telegram.core.objects.message.MessageReactionCountUpdated;
|
||||||
|
import hdvtdev.telegram.core.objects.message.MessageReactionUpdated;
|
||||||
|
import hdvtdev.telegram.core.objects.payment.PreCheckoutQuery;
|
||||||
|
import hdvtdev.telegram.core.objects.payment.ShippingQuery;
|
||||||
|
import hdvtdev.telegram.core.objects.poll.Poll;
|
||||||
|
import hdvtdev.telegram.core.objects.poll.PollAnswer;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface UpdateHandler extends UpdateConsumer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default void onUpdates(List<Update> updates) {
|
||||||
|
for (Update update : updates) {
|
||||||
|
if (update.hasMessage()) onMessage(update.message());
|
||||||
|
if (update.hasEditedMessage()) onEditedMessage(update.editedMessage());
|
||||||
|
if (update.hasChannelPost()) onChannelPost(update.channelPost());
|
||||||
|
if (update.hasEditedChannelPost()) onEditedChannelPost(update.editedChannelPost());
|
||||||
|
if (update.hasBusinessConnection()) onBusinessConnection(update.businessConnection());
|
||||||
|
if (update.hasBusinessMessage()) onBusinessMessage(update.businessMessage());
|
||||||
|
if (update.hasEditedBusinessMessage()) onEditedBusinessMessage(update.editedBusinessMessage());
|
||||||
|
if (update.hasDeletedBusinessMessages()) onDeletedBusinessMessages(update.businessMessagesDeleted());
|
||||||
|
if (update.hasMessageReaction()) onMessageReaction(update.messageReaction());
|
||||||
|
if (update.hasMessageReactionCount()) onMessageReactionCount(update.messageReactionCount());
|
||||||
|
if (update.hasInlineQuery()) onInlineQuery(update.inlineQuery());
|
||||||
|
if (update.hasChosenInlineResult()) onChosenInlineResult(update.chosenInlineResult());
|
||||||
|
if (update.hasCallbackQuery()) onCallbackQuery(update.callbackQuery());
|
||||||
|
if (update.hasShippingQuery()) onShippingQuery(update.shippingQuery());
|
||||||
|
if (update.hasPreCheckoutQuery()) onPreCheckoutQuery(update.preCheckoutQuery());
|
||||||
|
if (update.hasPurchasedPaidMedia()) onPaidMediaPurchased(update.paidMediaPurchased());
|
||||||
|
if (update.hasPoll()) onPoll(update.poll());
|
||||||
|
if (update.hasPollAnswer()) onPollAnswer(update.pollAnswer());
|
||||||
|
if (update.hasMyChatMember()) onMyChatMember(update.myChatMember());
|
||||||
|
if (update.hasChatMember()) onChatMember(update.chatMember());
|
||||||
|
if (update.hasChatJoinRequest()) onChatJoinRequest(update.chatJoinRequest());
|
||||||
|
if (update.hasChatBoost()) onChatBoost(update.chatBoost());
|
||||||
|
if (update.hasRemovedChatBoost()) onChatBoostRemoved(update.chatBoostRemoved());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
default void onMessage(Message message) {}
|
||||||
|
default void onEditedMessage(Message message) {}
|
||||||
|
default void onChannelPost(Message message) {}
|
||||||
|
default void onEditedChannelPost(Message message) {}
|
||||||
|
default void onBusinessConnection(BusinessConnection connection) {}
|
||||||
|
default void onBusinessMessage(Message message) {}
|
||||||
|
default void onEditedBusinessMessage(Message message) {}
|
||||||
|
default void onDeletedBusinessMessages(BusinessMessagesDeleted deleted) {}
|
||||||
|
default void onMessageReaction(MessageReactionUpdated reaction) {}
|
||||||
|
default void onMessageReactionCount(MessageReactionCountUpdated count) {}
|
||||||
|
default void onInlineQuery(InlineQuery query) {}
|
||||||
|
default void onChosenInlineResult(ChosenInlineResult result) {}
|
||||||
|
default void onCallbackQuery(CallbackQuery callbackQuery) {}
|
||||||
|
default void onShippingQuery(ShippingQuery query) {}
|
||||||
|
default void onPreCheckoutQuery(PreCheckoutQuery query) {}
|
||||||
|
default void onPaidMediaPurchased(PaidMediaPurchased paidMedia) {}
|
||||||
|
default void onPoll(Poll poll) {}
|
||||||
|
default void onPollAnswer(PollAnswer answer) {}
|
||||||
|
default void onMyChatMember(ChatMemberUpdated member) {}
|
||||||
|
default void onChatMember(ChatMemberUpdated member) {}
|
||||||
|
default void onChatJoinRequest(ChatJoinRequest request) {}
|
||||||
|
default void onChatBoost(ChatBoostUpdated boost) {}
|
||||||
|
default void onChatBoostRemoved(ChatBoostRemoved removedBoost) {}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
4
core/src/main/java/hdvtdev/telegram/core/UserState.java
Normal file
4
core/src/main/java/hdvtdev/telegram/core/UserState.java
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
package hdvtdev.telegram.core;
|
||||||
|
|
||||||
|
public interface UserState {
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package hdvtdev.telegram.core.annotaions;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.methods.TelegramApiMethod;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This annotation is used to indicate {@link TelegramApiMethod} that should be serialized into JSON.
|
||||||
|
* <h5>Last documentation update: 2025-04-05</h5>
|
||||||
|
* @see com.fasterxml.jackson.databind.ObjectMapper
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
public @interface Jsonable {
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package hdvtdev.telegram.core.exceptions;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
public class TelegramApiException extends IllegalArgumentException {
|
||||||
|
|
||||||
|
public TelegramApiException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TelegramApiException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TelegramApiException(ErrorResponse errorResponse) {
|
||||||
|
super(errorResponse.description);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TelegramApiException(Throwable throwable) {
|
||||||
|
super(throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ErrorResponse(boolean ok, @JsonProperty("error_code") int errorCode, String description) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package hdvtdev.telegram.core.exceptions;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class TelegramApiNetworkException extends RuntimeException {
|
||||||
|
public TelegramApiNetworkException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TelegramApiNetworkException(IOException e) {
|
||||||
|
super(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TelegramApiNetworkException(String s, IOException e) {
|
||||||
|
super(s, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package hdvtdev.telegram.core.exceptions;
|
||||||
|
|
||||||
|
public class TelegramMethodParsingException extends RuntimeException {
|
||||||
|
public TelegramMethodParsingException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TelegramMethodParsingException(Throwable throwable) {
|
||||||
|
super(throwable);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.objects.Game;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to send answers to callback queries sent from inline keyboards.
|
||||||
|
* The answer will be displayed to the user as a notification at the top of the chat screen or as an alert.
|
||||||
|
* Alternatively, the user can be redirected to the specified {@link Game} URL.
|
||||||
|
* For this option to work, you must first create a game for your command via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your command with a parameter.
|
||||||
|
* @apiNote On success, {@code Boolean == true} is returned.
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@NotTested
|
||||||
|
public final class AnswerCallbackQuery implements TelegramApiMethod<Boolean> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unique identifier for the query to be answered
|
||||||
|
*/
|
||||||
|
private final String callbackQueryId;
|
||||||
|
/**
|
||||||
|
* Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
|
||||||
|
*/
|
||||||
|
private String text;
|
||||||
|
/**
|
||||||
|
* If True, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
|
||||||
|
*/
|
||||||
|
private Boolean showAlert;
|
||||||
|
/**
|
||||||
|
* URL that will be opened by the user's client.
|
||||||
|
* If you have created a {@link Game} and accepted the conditions via @BotFather, specify the URL that opens your game.
|
||||||
|
* Otherwise, you may use links like t.me/your_bot?start=XXXX that open your command with a parameter.
|
||||||
|
* @apiNote this will only work if the query comes from a callback_game button.
|
||||||
|
*/
|
||||||
|
private String url;
|
||||||
|
/**
|
||||||
|
* The maximum amount of time in seconds that the result of the callback query may be cached client-side.
|
||||||
|
* Telegram apps will support caching starting in version 3.14. Defaults to 0.
|
||||||
|
*/
|
||||||
|
private Integer cacheTime;
|
||||||
|
|
||||||
|
public AnswerCallbackQuery(String callbackQueryId) {
|
||||||
|
this.callbackQueryId = callbackQueryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private AnswerCallbackQuery(Builder builder) {
|
||||||
|
callbackQueryId = builder.callbackQueryId;
|
||||||
|
text = builder.text;
|
||||||
|
showAlert = builder.showAlert;
|
||||||
|
url = builder.url;
|
||||||
|
cacheTime = builder.cacheTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
TelegramApiMethodBody body = new TelegramApiMethodBody();
|
||||||
|
body.add("callback_query_id", this.callbackQueryId);
|
||||||
|
body.add("text", this.text);
|
||||||
|
body.add("show_alert", String.valueOf(this.showAlert));
|
||||||
|
body.add("url", this.url);
|
||||||
|
body.add("cache_time", String.valueOf(this.cacheTime));
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "answerCallbackQuery";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<Boolean> getResponseClass() {
|
||||||
|
return Boolean.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private final String callbackQueryId;
|
||||||
|
private String text;
|
||||||
|
private Boolean showAlert;
|
||||||
|
private String url;
|
||||||
|
private Integer cacheTime;
|
||||||
|
|
||||||
|
public Builder(String callbackQueryId) {
|
||||||
|
this.callbackQueryId = callbackQueryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder text(String text) {
|
||||||
|
this.text = text;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder showAlert(Boolean showAlert) {
|
||||||
|
this.showAlert = showAlert;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder url(String url) {
|
||||||
|
this.url = url;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder cacheTime(Integer cacheTime) {
|
||||||
|
this.cacheTime = cacheTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnswerCallbackQuery build() {
|
||||||
|
return new AnswerCallbackQuery(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.objects.chat.Chat;
|
||||||
|
import hdvtdev.telegram.core.objects.chat.ChatAdministratorRights;
|
||||||
|
import hdvtdev.telegram.core.objects.User;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to approve a chat join request.
|
||||||
|
* The command must be an <u>administrator</u> in the chat for this to work and must have the {@link ChatAdministratorRights#canInviteUsers()} administrator right.
|
||||||
|
* Returns True on success.
|
||||||
|
* @param chatId Unique username of the target channel in the format @channelusername
|
||||||
|
* @param userId Unique identifier of the target user
|
||||||
|
* @see ChatAdministratorRights
|
||||||
|
* @see Chat
|
||||||
|
* @see Chat#id()
|
||||||
|
* @since 0.1.0
|
||||||
|
*/
|
||||||
|
//TODO NotTested
|
||||||
|
public record ApproveChatJoinRequest(String chatId, long userId) implements TelegramApiMethod<Boolean> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param chatId Unique identifier for the target chat
|
||||||
|
* @param userId Unique identifier of the target user
|
||||||
|
* @see User#id()
|
||||||
|
* @see Chat#id()
|
||||||
|
*/
|
||||||
|
public ApproveChatJoinRequest(long chatId, long userId) {
|
||||||
|
this(String.valueOf(chatId), userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
TelegramApiMethodBody body = new TelegramApiMethodBody();
|
||||||
|
body.add("chat_id", chatId);
|
||||||
|
body.add("user_id", String.valueOf(userId));
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "approveChatJoinRequest";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<Boolean> getResponseClass() {
|
||||||
|
return Boolean.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.objects.chat.ChatAdministratorRights;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to ban a user in a group, a supergroup or a channel.
|
||||||
|
* In the case of supergroups and channels, the user will not be able to return
|
||||||
|
* to the chat on their own using invite links, etc., unless unbanned first.
|
||||||
|
* The command must be an administrator in the chat for this to work and must have
|
||||||
|
* the appropriate administrator rights: {@link ChatAdministratorRights#canRestrictMembers()}. Returns True on success.
|
||||||
|
* @see ChatAdministratorRights
|
||||||
|
* @since 0.1.1
|
||||||
|
*/
|
||||||
|
//TODO NotTested
|
||||||
|
public final class BanChatMember implements TelegramApiMethod<Boolean> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername)
|
||||||
|
*/
|
||||||
|
private final String chatId;
|
||||||
|
/**
|
||||||
|
* Unique identifier of the target user
|
||||||
|
*/
|
||||||
|
private final long userId;
|
||||||
|
/**
|
||||||
|
* Date when the user will be unbanned; Unix time.
|
||||||
|
* If user is banned for more than 366 days or less than 30 seconds from
|
||||||
|
* the current time they are considered to be banned forever.
|
||||||
|
* Applied for supergroups and channels only.
|
||||||
|
*/
|
||||||
|
private Long untilDate;
|
||||||
|
/**
|
||||||
|
* Pass true to delete all message from the chat for the user that is being removed.
|
||||||
|
* If false, the user will be able to see message in the group that were sent before the user was removed.
|
||||||
|
* Always True for supergroups and channels.
|
||||||
|
*/
|
||||||
|
private Boolean revokeMessages;
|
||||||
|
|
||||||
|
public BanChatMember(String chatId, long userId) {
|
||||||
|
this.chatId = chatId;
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BanChatMember(long chatId, long userId) {
|
||||||
|
this.chatId = String.valueOf(chatId);
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BanChatMember(Builder builder) {
|
||||||
|
chatId = builder.chatId;
|
||||||
|
userId = builder.userId;
|
||||||
|
setUntilDate(builder.untilDate);
|
||||||
|
setRevokeMessages(builder.revokeMessages);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUntilDate(Long untilDate) {
|
||||||
|
this.untilDate = untilDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRevokeMessages(Boolean revokeMessages) {
|
||||||
|
this.revokeMessages = revokeMessages;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
TelegramApiMethodBody body = new TelegramApiMethodBody();
|
||||||
|
body.add("chat_id", this.chatId);
|
||||||
|
body.add("user_id", String.valueOf(userId));
|
||||||
|
body.add("until_date", String.valueOf(untilDate));
|
||||||
|
body.add("revoke_messages", String.valueOf(revokeMessages));
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "banChatMember";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<Boolean> getResponseClass() {
|
||||||
|
return Boolean.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private final String chatId;
|
||||||
|
private final long userId;
|
||||||
|
private Long untilDate;
|
||||||
|
private Boolean revokeMessages;
|
||||||
|
|
||||||
|
public Builder(String chatId, long userId) {
|
||||||
|
this.chatId = chatId;
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder untilDate(Long untilDate) {
|
||||||
|
this.untilDate = untilDate;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder revokeMessages(Boolean revokeMessages) {
|
||||||
|
this.revokeMessages = revokeMessages;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BanChatMember build() {
|
||||||
|
return new BanChatMember(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to ban a channel chat in a supergroup or a channel.
|
||||||
|
* Until the chat is unbanned, the owner of the banned chat won't be able to send message on behalf of
|
||||||
|
* their channels. The command must be an administrator in the supergroup or channel for this to
|
||||||
|
* work and must have the appropriate administrator rights. Returns True on success.
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
//TODO NotTested
|
||||||
|
public record BanChatSenderChat(String chatId, long userId) implements TelegramApiMethod<Boolean> {
|
||||||
|
|
||||||
|
public BanChatSenderChat(long chatId, long userId) {
|
||||||
|
this(String.valueOf(chatId), userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
TelegramApiMethodBody body = new TelegramApiMethodBody();
|
||||||
|
body.add("chat_id", chatId);
|
||||||
|
body.add("user_id", String.valueOf(userId));
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "banChatSenderChat";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<Boolean> getResponseClass() {
|
||||||
|
return Boolean.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.objects.chat.ChatAdministratorRights;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to close an open topic in a forum supergroup chat.
|
||||||
|
* The command must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights,
|
||||||
|
* unless it is the creator of the topic. Returns {@code true} on success.
|
||||||
|
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
||||||
|
* @param messageThreadId Unique identifier for the target message thread of the forum topic
|
||||||
|
* @see ChatAdministratorRights#canManageTopics()
|
||||||
|
*/
|
||||||
|
//TODO NotTested
|
||||||
|
public record CloseForumTopic(String chatId, long messageThreadId) implements TelegramApiMethod<Boolean> {
|
||||||
|
|
||||||
|
public CloseForumTopic(long chatId, long messageThreadId) {
|
||||||
|
this(String.valueOf(chatId), messageThreadId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
TelegramApiMethodBody body = new TelegramApiMethodBody();
|
||||||
|
body.add("chat_id", chatId);
|
||||||
|
body.add("message_thread_id", String.valueOf(messageThreadId));
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "closeForumTopic";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<Boolean> getResponseClass() {
|
||||||
|
return Boolean.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.objects.chat.ChatAdministratorRights;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to close an open 'General' topic in a forum supergroup chat.
|
||||||
|
* The command must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights.
|
||||||
|
* Returns {@code true} on success.
|
||||||
|
* @see ChatAdministratorRights#canManageTopics()
|
||||||
|
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
||||||
|
*/
|
||||||
|
// TODO NotTested
|
||||||
|
public record CloseGeneralForumTopic(String chatId) implements TelegramApiMethod<Boolean> {
|
||||||
|
|
||||||
|
public CloseGeneralForumTopic(long chatId) {
|
||||||
|
this(String.valueOf(chatId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
TelegramApiMethodBody body = new TelegramApiMethodBody();
|
||||||
|
body.add("chat_id", chatId);
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "closeGeneralForumTopic";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<Boolean> getResponseClass() {
|
||||||
|
return Boolean.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,242 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.annotaions.Jsonable;
|
||||||
|
import hdvtdev.telegram.core.methods.util.ParseMode;
|
||||||
|
import hdvtdev.telegram.core.objects.message.MessageEntity;
|
||||||
|
import hdvtdev.telegram.core.objects.poll.Poll;
|
||||||
|
import hdvtdev.telegram.core.objects.markup.ReplyMarkup;
|
||||||
|
import hdvtdev.telegram.core.objects.ReplyParameters;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to copy message of any kind.
|
||||||
|
* Service message, paid media message, giveaway message, giveaway winners message, and invoice message can't be copied.
|
||||||
|
* A quiz {@link Poll} can be copied only if the value of the field correct_option_id is known to the command.
|
||||||
|
* The method is analogous to the method {@link ForwardMessage}, but the copied message doesn't have a link to the original message.
|
||||||
|
* Returns the messageId as {@link Long} of the sent message on success.
|
||||||
|
* @see Poll#correctOptionId()
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
//TODO NotTested
|
||||||
|
@Jsonable
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public final class CopyMessage implements TelegramApiMethod<Long> {
|
||||||
|
|
||||||
|
@JsonProperty("chat_id")
|
||||||
|
private final String chatId;
|
||||||
|
@JsonProperty("message_thread_id")
|
||||||
|
private Long messageThreadId;
|
||||||
|
@JsonProperty("from_chat_id")
|
||||||
|
private final String fromChatId;
|
||||||
|
@JsonProperty("message_id")
|
||||||
|
private final long messageId;
|
||||||
|
@JsonProperty("video_start_timestamp")
|
||||||
|
private long videoStartTimestamp;
|
||||||
|
@JsonProperty("caption")
|
||||||
|
private String caption;
|
||||||
|
@JsonProperty("parse_mode")
|
||||||
|
private ParseMode parseMode;
|
||||||
|
@JsonProperty("caption_entities")
|
||||||
|
private List<MessageEntity> captionEntities;
|
||||||
|
@JsonProperty("show_caption_above_media")
|
||||||
|
private Boolean showCaptionAboveMedia;
|
||||||
|
@JsonProperty("disable_notification")
|
||||||
|
private Boolean disableNotification;
|
||||||
|
@JsonProperty("protect_content")
|
||||||
|
private Boolean protectContent;
|
||||||
|
@JsonProperty("allow_paid_broadcast")
|
||||||
|
private Boolean allowPaidBroadcast;
|
||||||
|
@JsonProperty("reply_parameters")
|
||||||
|
private ReplyParameters replyParameters;
|
||||||
|
@JsonProperty("reply_markup")
|
||||||
|
private ReplyMarkup replyMarkup;
|
||||||
|
|
||||||
|
public CopyMessage(String chatId, String fromChatId, long messageId) {
|
||||||
|
this.chatId = chatId;
|
||||||
|
this.fromChatId = fromChatId;
|
||||||
|
this.messageId = messageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CopyMessage(long chatId, String fromChatId, long messageId) {
|
||||||
|
this(String.valueOf(chatId), fromChatId, messageId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CopyMessage(long chatId, long fromChatId, long messageId) {
|
||||||
|
this(String.valueOf(chatId), String.valueOf(fromChatId), messageId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CopyMessage(String chatId, long fromChatId, long messageId) {
|
||||||
|
this(chatId, String.valueOf(fromChatId), messageId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CopyMessage(Builder builder) {
|
||||||
|
chatId = builder.chatId;
|
||||||
|
setMessageThreadId(builder.messageThreadId);
|
||||||
|
fromChatId = builder.fromChatId;
|
||||||
|
messageId = builder.messageId;
|
||||||
|
setVideoStartTimestamp(builder.videoStartTimestamp);
|
||||||
|
setCaption(builder.caption);
|
||||||
|
setParseMode(builder.parseMode);
|
||||||
|
setCaptionEntities(builder.captionEntities);
|
||||||
|
setShowCaptionAboveMedia(builder.showCaptionAboveMedia);
|
||||||
|
setDisableNotification(builder.disableNotification);
|
||||||
|
setProtectContent(builder.protectContent);
|
||||||
|
setAllowPaidBroadcast(builder.allowPaidBroadcast);
|
||||||
|
setReplyParameters(builder.replyParameters);
|
||||||
|
setReplyMarkup(builder.replyMarkup);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageThreadId(Long messageThreadId) {
|
||||||
|
this.messageThreadId = messageThreadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVideoStartTimestamp(long videoStartTimestamp) {
|
||||||
|
this.videoStartTimestamp = videoStartTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCaption(String caption) {
|
||||||
|
this.caption = caption;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParseMode(ParseMode parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCaptionEntities(List<MessageEntity> captionEntities) {
|
||||||
|
this.captionEntities = captionEntities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowCaptionAboveMedia(Boolean showCaptionAboveMedia) {
|
||||||
|
this.showCaptionAboveMedia = showCaptionAboveMedia;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisableNotification(Boolean disableNotification) {
|
||||||
|
this.disableNotification = disableNotification;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProtectContent(Boolean protectContent) {
|
||||||
|
this.protectContent = protectContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllowPaidBroadcast(Boolean allowPaidBroadcast) {
|
||||||
|
this.allowPaidBroadcast = allowPaidBroadcast;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReplyParameters(ReplyParameters replyParameters) {
|
||||||
|
this.replyParameters = replyParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReplyMarkup(ReplyMarkup replyMarkup) {
|
||||||
|
this.replyMarkup = replyMarkup;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "copyMessage";
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public Class<Long> getResponseClass() {
|
||||||
|
return Long.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private final String chatId;
|
||||||
|
private Long messageThreadId;
|
||||||
|
private final String fromChatId;
|
||||||
|
private final long messageId;
|
||||||
|
private long videoStartTimestamp;
|
||||||
|
private String caption;
|
||||||
|
private ParseMode parseMode;
|
||||||
|
private List<MessageEntity> captionEntities;
|
||||||
|
private Boolean showCaptionAboveMedia;
|
||||||
|
private Boolean disableNotification;
|
||||||
|
private Boolean protectContent;
|
||||||
|
private Boolean allowPaidBroadcast;
|
||||||
|
private ReplyParameters replyParameters;
|
||||||
|
private ReplyMarkup replyMarkup;
|
||||||
|
|
||||||
|
public Builder(String chatId, String fromChatId, long messageId) {
|
||||||
|
this.chatId = chatId;
|
||||||
|
this.fromChatId = fromChatId;
|
||||||
|
this.messageId = messageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder(long chatId, String fromChatId, long messageId) {
|
||||||
|
this(String.valueOf(chatId), fromChatId, messageId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder messageThreadId(Long messageThreadId) {
|
||||||
|
this.messageThreadId = messageThreadId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder videoStartTimestamp(long videoStartTimestamp) {
|
||||||
|
this.videoStartTimestamp = videoStartTimestamp;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder caption(String caption) {
|
||||||
|
this.caption = caption;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder parseMode(ParseMode parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder captionEntities(List<MessageEntity> captionEntities) {
|
||||||
|
this.captionEntities = captionEntities;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder showCaptionAboveMedia(Boolean showCaptionAboveMedia) {
|
||||||
|
this.showCaptionAboveMedia = showCaptionAboveMedia;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder disableNotification(Boolean disableNotification) {
|
||||||
|
this.disableNotification = disableNotification;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder protectContent(Boolean protectContent) {
|
||||||
|
this.protectContent = protectContent;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder allowPaidBroadcast(Boolean allowPaidBroadcast) {
|
||||||
|
this.allowPaidBroadcast = allowPaidBroadcast;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder replyParameters(ReplyParameters replyParameters) {
|
||||||
|
this.replyParameters = replyParameters;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder replyMarkup(ReplyMarkup replyMarkup) {
|
||||||
|
this.replyMarkup = replyMarkup;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CopyMessage build() {
|
||||||
|
return new CopyMessage(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,179 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.annotaions.Jsonable;
|
||||||
|
import hdvtdev.telegram.core.objects.poll.Poll;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to copy message of any kind.
|
||||||
|
* If some of the specified message can't be found or copied, they are skipped.
|
||||||
|
* Service message, paid media message, giveaway message, giveaway winners message, and invoice message can't be copied.
|
||||||
|
* A quiz {@link Poll} can be copied only if the value of the field correct_option_id is known to the command.
|
||||||
|
* The method is analogous to the method {@link ForwardMessages}, but the copied message don't have a link to the original message.
|
||||||
|
* Album grouping is kept for copied message.
|
||||||
|
* On success, an array of MessageId as {@link Long}{@code []} of the sent message is returned.
|
||||||
|
* @see Poll#correctOptionId()
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
@Jsonable
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public final class CopyMessages implements TelegramApiMethod<Long[]> {
|
||||||
|
|
||||||
|
@JsonProperty("chat_id")
|
||||||
|
private final String chatId;
|
||||||
|
@JsonProperty("message_thread_id")
|
||||||
|
private Long messageThreadId;
|
||||||
|
@JsonProperty("from_chat_id")
|
||||||
|
private final String fromChatId;
|
||||||
|
@JsonProperty("message_id")
|
||||||
|
private final List<Long> messageIds;
|
||||||
|
@JsonProperty("disable_notification")
|
||||||
|
private Boolean disableNotification;
|
||||||
|
@JsonProperty("protect_content")
|
||||||
|
private Boolean protectContent;
|
||||||
|
@JsonProperty("remove_caption")
|
||||||
|
private Boolean removeCaption;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param chatId Username of the target channel (in the format @channelusername)
|
||||||
|
* @param fromChatId Channel username in the format @channelusername for the chat where the original message were sent
|
||||||
|
* @param messageIds List of 1-100 identifiers of message in the chat to copy.
|
||||||
|
*/
|
||||||
|
public CopyMessages(String chatId, String fromChatId, List<Long> messageIds) {
|
||||||
|
this.chatId = chatId;
|
||||||
|
this.fromChatId = fromChatId;
|
||||||
|
ArrayList<Long> sortedMessageIds = new ArrayList<>(messageIds.subList(0, Math.min(messageIds.size(), 100)));
|
||||||
|
sortedMessageIds.sort(null);
|
||||||
|
this.messageIds = sortedMessageIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param chatId Unique identifier for the target chat
|
||||||
|
* @param fromChatId Channel username in the format @channelusername for the chat where the original message were sent
|
||||||
|
* @param messageIds List of 1-100 identifiers of message in the chat to copy.
|
||||||
|
*/
|
||||||
|
public CopyMessages(long chatId, String fromChatId, List<Long> messageIds) {
|
||||||
|
this(String.valueOf(chatId), fromChatId, messageIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param chatId Unique identifier for the target chat
|
||||||
|
* @param fromChatId Unique identifier for the chat where the original message were sent
|
||||||
|
* @param messageIds List of 1-100 identifiers of message in the chat to copy.
|
||||||
|
*/
|
||||||
|
public CopyMessages(long chatId, long fromChatId, List<Long> messageIds) {
|
||||||
|
this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param chatId Channel username in the format @channelusername for the chat where the original message were sent
|
||||||
|
* @param fromChatId Unique identifier for the target chat
|
||||||
|
* @param messageIds List of 1-100 identifiers of message in the chat to copy.
|
||||||
|
*/
|
||||||
|
public CopyMessages(String chatId, long fromChatId, List<Long> messageIds) {
|
||||||
|
this(chatId, String.valueOf(fromChatId), messageIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CopyMessages(Builder builder) {
|
||||||
|
chatId = builder.chatId;
|
||||||
|
setMessageThreadId(builder.messageThreadId);
|
||||||
|
fromChatId = builder.fromChatId;
|
||||||
|
messageIds = builder.messageIds;
|
||||||
|
setDisableNotification(builder.disableNotification);
|
||||||
|
setProtectContent(builder.protectContent);
|
||||||
|
setRemoveCaption(builder.removeCaption);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageThreadId(Long messageThreadId) {
|
||||||
|
this.messageThreadId = messageThreadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisableNotification(Boolean disableNotification) {
|
||||||
|
this.disableNotification = disableNotification;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProtectContent(Boolean protectContent) {
|
||||||
|
this.protectContent = protectContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemoveCaption(Boolean removeCaption) {
|
||||||
|
this.removeCaption = removeCaption;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "copyMessages";
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public Class<Long[]> getResponseClass() {
|
||||||
|
return Long[].class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private final String chatId;
|
||||||
|
private Long messageThreadId;
|
||||||
|
private final String fromChatId;
|
||||||
|
private final List<Long> messageIds;
|
||||||
|
private Boolean disableNotification;
|
||||||
|
private Boolean protectContent;
|
||||||
|
private Boolean removeCaption;
|
||||||
|
|
||||||
|
public Builder(String chatId, String fromChatId, List<Long> messageIds) {
|
||||||
|
this.chatId = chatId;
|
||||||
|
this.fromChatId = fromChatId;
|
||||||
|
ArrayList<Long> sortedMessageIds = new ArrayList<>(messageIds.subList(0, Math.min(messageIds.size(), 100)));
|
||||||
|
sortedMessageIds.sort(null);
|
||||||
|
this.messageIds = sortedMessageIds;
|
||||||
|
}
|
||||||
|
public Builder(long chatId, String fromChatId, List<Long> messageIds) {
|
||||||
|
this(String.valueOf(chatId), fromChatId, messageIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder(long chatId, long fromChatId, List<Long> messageIds) {
|
||||||
|
this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder(String chatId, long fromChatId, List<Long> messageIds) {
|
||||||
|
this(chatId, String.valueOf(fromChatId), messageIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder messageThreadId(Long messageThreadId) {
|
||||||
|
this.messageThreadId = messageThreadId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder disableNotification(Boolean disableNotification) {
|
||||||
|
this.disableNotification = disableNotification;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder protectContent(Boolean protectContent) {
|
||||||
|
this.protectContent = protectContent;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder removeCaption(Boolean removeCaption) {
|
||||||
|
this.removeCaption = removeCaption;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CopyMessages build() {
|
||||||
|
return new CopyMessages(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.objects.chat.ChatAdministratorRights;
|
||||||
|
import hdvtdev.telegram.core.objects.chat.ChatInviteLink;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to create an additional invite link for a chat.
|
||||||
|
* The command must be an administrator in the chat for this to work and must have the appropriate administrator rights.
|
||||||
|
* The link can be revoked using the method {@link RevokeChatInviteLink}. Returns the new invite link as {@link ChatInviteLink} object.
|
||||||
|
* @see ChatAdministratorRights#canInviteUsers()
|
||||||
|
*/
|
||||||
|
public final class CreateChatInviteLink implements TelegramApiMethod<ChatInviteLink> {
|
||||||
|
|
||||||
|
private final String chatId;
|
||||||
|
private String name;
|
||||||
|
private Long expireDate;
|
||||||
|
private Integer memberLimit;
|
||||||
|
private Boolean createsJoinRequest;
|
||||||
|
|
||||||
|
public CreateChatInviteLink(String chatId) {
|
||||||
|
this.chatId = chatId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateChatInviteLink(long chatId) {
|
||||||
|
this(String.valueOf(chatId));
|
||||||
|
}
|
||||||
|
|
||||||
|
private CreateChatInviteLink(Builder builder) {
|
||||||
|
chatId = builder.chatId;
|
||||||
|
setName(builder.name);
|
||||||
|
setExpireDate(builder.expireDate);
|
||||||
|
setMemberLimit(builder.memberLimit);
|
||||||
|
setCreatesJoinRequest(builder.createsJoinRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpireDate(Long expireDate) {
|
||||||
|
this.expireDate = expireDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberLimit(Integer memberLimit) {
|
||||||
|
this.memberLimit = memberLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatesJoinRequest(Boolean createsJoinRequest) {
|
||||||
|
this.createsJoinRequest = createsJoinRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
TelegramApiMethodBody body = new TelegramApiMethodBody();
|
||||||
|
body.add("name", name);
|
||||||
|
body.add("chat_id", chatId);
|
||||||
|
body.add("expire_date", String.valueOf(expireDate));
|
||||||
|
body.add("member_limit", String.valueOf(memberLimit));
|
||||||
|
body.add("creates_join_request", String.valueOf(createsJoinRequest));
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "createChatInviteLink";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<ChatInviteLink> getResponseClass() {
|
||||||
|
return ChatInviteLink.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private final String chatId;
|
||||||
|
private String name;
|
||||||
|
private Long expireDate;
|
||||||
|
private Integer memberLimit;
|
||||||
|
private Boolean createsJoinRequest;
|
||||||
|
|
||||||
|
public Builder(String chatId) {
|
||||||
|
this.chatId = chatId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder(long chatId) {
|
||||||
|
this(String.valueOf(chatId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder expireDate(Long expireDate) {
|
||||||
|
this.expireDate = expireDate;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder memberLimit(Integer memberLimit) {
|
||||||
|
this.memberLimit = memberLimit;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder createsJoinRequest(Boolean createsJoinRequest) {
|
||||||
|
this.createsJoinRequest = createsJoinRequest;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateChatInviteLink build() {
|
||||||
|
return new CreateChatInviteLink(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.annotaions.Jsonable;
|
||||||
|
import hdvtdev.telegram.core.objects.message.Message;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to forward message of any kind.
|
||||||
|
* Service message and message with protected content can't be forwarded.
|
||||||
|
* On success, the sent {@link Message} is returned.
|
||||||
|
*/
|
||||||
|
@Jsonable
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public final class ForwardMessage implements TelegramApiMethod<Message> {
|
||||||
|
|
||||||
|
@JsonProperty("chat_id")
|
||||||
|
private final String chatId;
|
||||||
|
@JsonProperty("message_thread_id")
|
||||||
|
private Long messageThreadId;
|
||||||
|
@JsonProperty("from_chat_id")
|
||||||
|
private final String fromChatId;
|
||||||
|
@JsonProperty("message_id")
|
||||||
|
private final long messageId;
|
||||||
|
@JsonProperty("disable_notification")
|
||||||
|
private Boolean disableNotification;
|
||||||
|
@JsonProperty("protect_content")
|
||||||
|
private Boolean protectContent;
|
||||||
|
@JsonProperty("video_start_timestamp")
|
||||||
|
private long videoStartTimestamp;
|
||||||
|
|
||||||
|
public ForwardMessage(String chatId, String fromChatId, long messageId) {
|
||||||
|
this.chatId = chatId;
|
||||||
|
this.fromChatId = fromChatId;
|
||||||
|
this.messageId = messageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForwardMessage(long chatId, String fromChatId, long messageId) {
|
||||||
|
this(String.valueOf(chatId), fromChatId, messageId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForwardMessage(long chatId, long fromChatId, long messageId) {
|
||||||
|
this(String.valueOf(chatId), String.valueOf(fromChatId), messageId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ForwardMessage(Builder builder) {
|
||||||
|
chatId = builder.chatId;
|
||||||
|
setMessageThreadId(builder.messageThreadId);
|
||||||
|
fromChatId = builder.fromChatId;
|
||||||
|
messageId = builder.messageId;
|
||||||
|
setDisableNotification(builder.disableNotification);
|
||||||
|
setProtectContent(builder.protectContent);
|
||||||
|
setVideoStartTimestamp(builder.videoStartTimestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageThreadId(Long messageThreadId) {
|
||||||
|
this.messageThreadId = messageThreadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisableNotification(Boolean disableNotification) {
|
||||||
|
this.disableNotification = disableNotification;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProtectContent(Boolean protectContent) {
|
||||||
|
this.protectContent = protectContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVideoStartTimestamp(long videoStartTimestamp) {
|
||||||
|
this.videoStartTimestamp = videoStartTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "forwardMessage";
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public Class<Message> getResponseClass() {
|
||||||
|
return Message.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private final String chatId;
|
||||||
|
private Long messageThreadId;
|
||||||
|
private final String fromChatId;
|
||||||
|
private final long messageId;
|
||||||
|
private Boolean disableNotification;
|
||||||
|
private Boolean protectContent;
|
||||||
|
private long videoStartTimestamp;
|
||||||
|
|
||||||
|
public Builder(String chatId, String fromChatId, long messageId) {
|
||||||
|
this.chatId = chatId;
|
||||||
|
this.fromChatId = fromChatId;
|
||||||
|
this.messageId = messageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder messageThreadId(Long messageThreadId) {
|
||||||
|
this.messageThreadId = messageThreadId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder disableNotification(Boolean disableNotification) {
|
||||||
|
this.disableNotification = disableNotification;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder protectContent(Boolean protectContent) {
|
||||||
|
this.protectContent = protectContent;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder videoStartTimestamp(long videoStartTimestamp) {
|
||||||
|
this.videoStartTimestamp = videoStartTimestamp;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForwardMessage build() {
|
||||||
|
return new ForwardMessage(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.annotaions.Jsonable;
|
||||||
|
import hdvtdev.telegram.core.objects.message.Message;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to forward multiple message of any kind. If some of the specified message can't be found or forwarded, they are skipped.
|
||||||
|
* Service message and message with protected content can't be forwarded. Album grouping is kept for forwarded message.
|
||||||
|
* On success, an array of MessageId as {@link Long} of the sent message is returned.
|
||||||
|
* @see Message#hasProtectedContent()
|
||||||
|
*/
|
||||||
|
// TODO NotTested
|
||||||
|
@Jsonable
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public final class ForwardMessages implements TelegramApiMethod<Long[]> {
|
||||||
|
|
||||||
|
@JsonProperty("chat_id")
|
||||||
|
private final String chatId;
|
||||||
|
@JsonProperty("message_thread_id")
|
||||||
|
private Long messageThreadId;
|
||||||
|
@JsonProperty("from_chat_id")
|
||||||
|
private final String fromChatId;
|
||||||
|
@JsonProperty("message_id")
|
||||||
|
private final List<Long> messageIds;
|
||||||
|
@JsonProperty("disable_notification")
|
||||||
|
private Boolean disableNotification;
|
||||||
|
@JsonProperty("protect_content")
|
||||||
|
private Boolean protectContent;
|
||||||
|
|
||||||
|
public ForwardMessages(String chatId, String fromChatId, List<Long> messageIds) {
|
||||||
|
ArrayList<Long> sortedMessageIds = new ArrayList<>(messageIds.size() > 100 ? messageIds.subList(0, 100) : messageIds);
|
||||||
|
sortedMessageIds.sort(null);
|
||||||
|
this.chatId = chatId;
|
||||||
|
this.fromChatId = fromChatId;
|
||||||
|
this.messageIds = sortedMessageIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForwardMessages(long chatId, String fromChatId, List<Long> messageIds) {
|
||||||
|
this(String.valueOf(chatId), fromChatId, messageIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForwardMessages(String chatId, long fromChatId, List<Long> messageIds) {
|
||||||
|
this(chatId, String.valueOf(fromChatId), messageIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForwardMessages(long chatId, long fromChatId, List<Long> messageIds) {
|
||||||
|
this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ForwardMessages(Builder builder) {
|
||||||
|
chatId = builder.chatId;
|
||||||
|
messageThreadId = builder.messageThreadId;
|
||||||
|
fromChatId = builder.fromChatId;
|
||||||
|
messageIds = builder.messageIds;
|
||||||
|
disableNotification = builder.disableNotification;
|
||||||
|
protectContent = builder.protectContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageThreadId(long messageThreadId) {
|
||||||
|
this.messageThreadId = messageThreadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisableNotification(boolean disableNotification) {
|
||||||
|
this.disableNotification = disableNotification;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProtectContent(boolean protectContent) {
|
||||||
|
this.protectContent = protectContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "forwardMessages";
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public Class<Long[]> getResponseClass() {
|
||||||
|
return Long[].class;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private final String chatId;
|
||||||
|
private Long messageThreadId;
|
||||||
|
private final String fromChatId;
|
||||||
|
private final List<Long> messageIds;
|
||||||
|
private Boolean disableNotification;
|
||||||
|
private Boolean protectContent;
|
||||||
|
|
||||||
|
public Builder(String chatId, String fromChatId, List<Long> messageIds) {
|
||||||
|
ArrayList<Long> sortedMessageIds = new ArrayList<>(messageIds.size() > 100 ? messageIds.subList(0, 100) : messageIds);
|
||||||
|
sortedMessageIds.sort(null);
|
||||||
|
this.chatId = chatId;
|
||||||
|
this.fromChatId = fromChatId;
|
||||||
|
this.messageIds = sortedMessageIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder(long chatId, String fromChatId, List<Long> messageIds) {
|
||||||
|
this(String.valueOf(chatId), fromChatId, messageIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder(String chatId, long fromChatId, List<Long> messageIds) {
|
||||||
|
this(chatId, String.valueOf(fromChatId), messageIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder(long chatId, long fromChatId, List<Long> messageIds) {
|
||||||
|
this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder messageThreadId(long messageThreadId) {
|
||||||
|
this.messageThreadId = messageThreadId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder disableNotification(boolean disableNotification) {
|
||||||
|
this.disableNotification = disableNotification;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder protectContent(boolean protectContent) {
|
||||||
|
this.protectContent = protectContent;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForwardMessages build() {
|
||||||
|
return new ForwardMessages(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.objects.chat.ChatMember;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of {@link ChatMember} objects.
|
||||||
|
* @param chatId
|
||||||
|
*/
|
||||||
|
//TODO NotTested
|
||||||
|
public record GetChatAdministrators(String chatId) implements TelegramApiMethod<ChatMember[]> {
|
||||||
|
|
||||||
|
public GetChatAdministrators(long chatId) {
|
||||||
|
this(String.valueOf(chatId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
TelegramApiMethodBody body = new TelegramApiMethodBody();
|
||||||
|
body.add("chat_id", chatId);
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "getChatAdministrators";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<ChatMember[]> getResponseClass() {
|
||||||
|
return ChatMember[].class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.objects.chat.ChatMember;
|
||||||
|
|
||||||
|
public record GetChatMember(String chatId, long userId) implements TelegramApiMethod<ChatMember> {
|
||||||
|
|
||||||
|
public GetChatMember(long chatId, long userId) {
|
||||||
|
this(String.valueOf(chatId), userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GetChatMember(String chatId, String userId) {
|
||||||
|
this(chatId, Long.parseLong(userId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public GetChatMember(long chatId, String userId) {
|
||||||
|
this(String.valueOf(chatId), userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
TelegramApiMethodBody body = new TelegramApiMethodBody();
|
||||||
|
body.add("chat_id", chatId);
|
||||||
|
body.add("user_id", String.valueOf(userId));
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "getChatMember";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<ChatMember> getResponseClass() {
|
||||||
|
return ChatMember.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.objects.media.TelegramFile;
|
||||||
|
|
||||||
|
public record GetFile(String fileId) implements TelegramApiMethod<TelegramFile> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
TelegramApiMethodBody body = new TelegramApiMethodBody();
|
||||||
|
body.add("file_id", fileId);
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "getFile";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<TelegramFile> getResponseClass() {
|
||||||
|
return TelegramFile.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
21
core/src/main/java/hdvtdev/telegram/core/methods/GetMe.java
Normal file
21
core/src/main/java/hdvtdev/telegram/core/methods/GetMe.java
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.objects.User;
|
||||||
|
|
||||||
|
public final class GetMe implements TelegramApiMethod<User.Bot> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "getMe";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<User.Bot> getResponseClass() {
|
||||||
|
return User.Bot.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.annotaions.Jsonable;
|
||||||
|
import hdvtdev.telegram.core.objects.command.BotCommand;
|
||||||
|
import hdvtdev.telegram.core.objects.command.BotCommandScope;
|
||||||
|
import hdvtdev.telegram.core.objects.command.BotCommandScopeDefault;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to get the current list of the command's commands for the given scope and user language.
|
||||||
|
* Returns an Array of {@link BotCommand} objects. If commands aren't set, an empty list is returned.
|
||||||
|
* @param scope Scope of users. Defaults to {@link BotCommandScopeDefault}.
|
||||||
|
* @param languageCode A two-letter ISO 639-1 language code or an empty string
|
||||||
|
* @see BotCommandScope
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
@Jsonable
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public record GetMyCommands(
|
||||||
|
@JsonProperty("scope") BotCommandScope scope,
|
||||||
|
@JsonProperty("language_code") String languageCode
|
||||||
|
) implements TelegramApiMethod<BotCommand[]> {
|
||||||
|
|
||||||
|
public GetMyCommands() {
|
||||||
|
this(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GetMyCommands(String languageCode) {
|
||||||
|
this(null, languageCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GetMyCommands(BotCommandScope scope) {
|
||||||
|
this(scope, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "getMyCommands";
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public Class<BotCommand[]> getResponseClass() {
|
||||||
|
return BotCommand[].class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
public record GetMyDescription(String languageCode) implements TelegramApiMethod<GetMyDescription.BotDescription> {
|
||||||
|
|
||||||
|
public GetMyDescription() {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
if (languageCode == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
TelegramApiMethodBody body = new TelegramApiMethodBody();
|
||||||
|
body.add("language_code", languageCode);
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "getMyDescription";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<BotDescription> getResponseClass() {
|
||||||
|
return BotDescription.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public record BotDescription(String description) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return description.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
public record GetMyName(String languageCode) implements TelegramApiMethod<GetMyName.BotName> {
|
||||||
|
|
||||||
|
public GetMyName() {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
if (languageCode == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
TelegramApiMethodBody body = new TelegramApiMethodBody();
|
||||||
|
body.add("language_code", languageCode);
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "getMyName";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<BotName> getResponseClass() {
|
||||||
|
return BotName.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public record BotName(String name) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.objects.Update;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public record GetUpdates(
|
||||||
|
Long offset,
|
||||||
|
Integer limit,
|
||||||
|
Integer timeout
|
||||||
|
) implements TelegramApiMethod<Update[]> {
|
||||||
|
|
||||||
|
public GetUpdates() {
|
||||||
|
this(null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
ArrayList<String> params = new ArrayList<>(3);
|
||||||
|
if (offset != null) params.add("offset=" + offset);
|
||||||
|
if (limit != null) params.add("limit=" + limit);
|
||||||
|
if (timeout != null) params.add("timeout=" + timeout);
|
||||||
|
|
||||||
|
if (params.isEmpty()) {
|
||||||
|
return "getUpdates";
|
||||||
|
} else {
|
||||||
|
return "getUpdates?" + String.join("&", params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<Update[]> getResponseClass() {
|
||||||
|
return Update[].class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.objects.chat.ChatInviteLink;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to revoke an invite link created by the command. If the primary link is revoked, a new link is automatically generated.
|
||||||
|
* The command must be an administrator in the chat for this to work and must have the appropriate administrator rights.
|
||||||
|
* Returns the revoked invite link as {@link ChatInviteLink} object.
|
||||||
|
* @param chatId Unique identifier of the target chat or username of the target channel (in the format @channelusername)
|
||||||
|
* @param link The invite link to revoke
|
||||||
|
*/
|
||||||
|
public record RevokeChatInviteLink(String chatId, String link) implements TelegramApiMethod<ChatInviteLink> {
|
||||||
|
|
||||||
|
public RevokeChatInviteLink(long chatId, String link) {
|
||||||
|
this(String.valueOf(chatId), link);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
TelegramApiMethodBody body = new TelegramApiMethodBody(2);
|
||||||
|
body.add("chat_id", chatId);
|
||||||
|
body.add("link", link);
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "revokeChatInviteLink";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<ChatInviteLink> getResponseClass() {
|
||||||
|
return ChatInviteLink.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
public final class SendChatAction implements TelegramApiMethod<Boolean> {
|
||||||
|
|
||||||
|
private String businessConnectionId;
|
||||||
|
private final String chatId;
|
||||||
|
private Long messageThreadId;
|
||||||
|
private final ChatAction chatAction;
|
||||||
|
|
||||||
|
public SendChatAction(String businessConnectionId, String chatId, Long messageThreadId, ChatAction chatAction) {
|
||||||
|
this.businessConnectionId = businessConnectionId;
|
||||||
|
this.chatId = chatId;
|
||||||
|
this.messageThreadId = messageThreadId;
|
||||||
|
this.chatAction = chatAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendChatAction(String chatId, ChatAction chatAction) {
|
||||||
|
this(null, chatId, null, chatAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendChatAction(long chatId, ChatAction chatAction) {
|
||||||
|
this(String.valueOf(chatId), chatAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
private SendChatAction(Builder builder) {
|
||||||
|
this(builder.businessConnectionId, builder.chatId, builder.messageThreadId, builder.chatAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBusinessConnectionId(String businessConnectionId) {
|
||||||
|
this.businessConnectionId = businessConnectionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageThreadId(Long messageThreadId) {
|
||||||
|
this.messageThreadId = messageThreadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
TelegramApiMethodBody body = new TelegramApiMethodBody();
|
||||||
|
body.add("chat_id", chatId);
|
||||||
|
body.add("action", chatAction.equals(ChatAction.UPLOAD_FILE) ? ChatAction.UPLOAD_DOCUMENT.name() : chatAction.name());
|
||||||
|
body.add("business_connection_id", businessConnectionId);
|
||||||
|
body.add("message_thread_id", String.valueOf(messageThreadId));
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "sendChatAction";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<Boolean> getResponseClass() {
|
||||||
|
return Boolean.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ChatAction {
|
||||||
|
TYPING,
|
||||||
|
UPLOAD_PHOTO,
|
||||||
|
RECORD_VIDEO,
|
||||||
|
UPLOAD_VIDEO,
|
||||||
|
RECORD_VOICE,
|
||||||
|
UPLOAD_VOICE,
|
||||||
|
UPLOAD_DOCUMENT,
|
||||||
|
UPLOAD_FILE,
|
||||||
|
CHOOSE_STICKER,
|
||||||
|
FIND_LOCATION,
|
||||||
|
RECORD_VIDEO_NOTE,
|
||||||
|
UPLOAD_VIDEO_NOTE
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private String businessConnectionId;
|
||||||
|
private final String chatId;
|
||||||
|
private Long messageThreadId;
|
||||||
|
private final ChatAction chatAction;
|
||||||
|
|
||||||
|
public Builder(String chatId, ChatAction chatAction) {
|
||||||
|
this.chatId = chatId;
|
||||||
|
this.chatAction = chatAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder businessConnectionId(String businessConnectionId) {
|
||||||
|
this.businessConnectionId = businessConnectionId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder messageThreadId(Long messageThreadId) {
|
||||||
|
this.messageThreadId = messageThreadId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendChatAction build() {
|
||||||
|
return new SendChatAction(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
131
core/src/main/java/hdvtdev/telegram/core/methods/SendDice.java
Normal file
131
core/src/main/java/hdvtdev/telegram/core/methods/SendDice.java
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.annotaions.Jsonable;
|
||||||
|
import hdvtdev.telegram.core.objects.message.Message;
|
||||||
|
import hdvtdev.telegram.core.objects.markup.ReplyMarkup;
|
||||||
|
import hdvtdev.telegram.core.objects.ReplyParameters;
|
||||||
|
|
||||||
|
@Jsonable
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public final class SendDice implements TelegramApiMethod<Message> {
|
||||||
|
|
||||||
|
@JsonProperty("chat_id")
|
||||||
|
private final String chatId;
|
||||||
|
@JsonProperty("business_connection_id")
|
||||||
|
private String businessConnectionId;
|
||||||
|
@JsonProperty("message_thread_id")
|
||||||
|
private Long messageThreadId;
|
||||||
|
@JsonProperty("emoji")
|
||||||
|
private String emoji;
|
||||||
|
@JsonProperty("disable_notification")
|
||||||
|
private Boolean disableNotification;
|
||||||
|
@JsonProperty("protect_content")
|
||||||
|
private Boolean protectContent;
|
||||||
|
@JsonProperty("allow_paid_broadcast")
|
||||||
|
private Boolean allowPaidBroadcast;
|
||||||
|
@JsonProperty("message_effect_id")
|
||||||
|
private String messageEffectId;
|
||||||
|
@JsonProperty("reply_parameters")
|
||||||
|
private ReplyParameters replyParameters;
|
||||||
|
@JsonProperty("reply_markup")
|
||||||
|
private ReplyMarkup replyMarkup;
|
||||||
|
|
||||||
|
public SendDice(String chatId) {
|
||||||
|
this.chatId = chatId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendDice(long chatId) {
|
||||||
|
this(String.valueOf(chatId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendDice(String chatId, Emoji emoji) {
|
||||||
|
this.emoji = emoji.getEmoji();
|
||||||
|
this.chatId = chatId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendDice(long chatId, Emoji emoji) {
|
||||||
|
this(String.valueOf(chatId), emoji);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setBusinessConnectionId(String businessConnectionId) {
|
||||||
|
this.businessConnectionId = businessConnectionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageThreadId(Long messageThreadId) {
|
||||||
|
this.messageThreadId = messageThreadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmoji(Emoji emoji) {
|
||||||
|
this.emoji = emoji.getEmoji();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisableNotification(Boolean disableNotification) {
|
||||||
|
this.disableNotification = disableNotification;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProtectContent(Boolean protectContent) {
|
||||||
|
this.protectContent = protectContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllowPaidBroadcast(Boolean allowPaidBroadcast) {
|
||||||
|
this.allowPaidBroadcast = allowPaidBroadcast;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageEffectId(String messageEffectId) {
|
||||||
|
this.messageEffectId = messageEffectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReplyParameters(ReplyParameters replyParameters) {
|
||||||
|
this.replyParameters = replyParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReplyMarkup(ReplyMarkup replyMarkup) {
|
||||||
|
this.replyMarkup = replyMarkup;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "sendDice";
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public Class<Message> getResponseClass() {
|
||||||
|
return Message.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Emoji {
|
||||||
|
DICE("🎲"),
|
||||||
|
DART("🎯"),
|
||||||
|
BASKETBALL("🏀"),
|
||||||
|
FOOTBALL("⚽"),
|
||||||
|
BOWLING("🎳"),
|
||||||
|
SLOT_MACHINE("🎰");
|
||||||
|
|
||||||
|
private final String emoji;
|
||||||
|
|
||||||
|
Emoji(String emoji) {
|
||||||
|
this.emoji = emoji;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmoji() {
|
||||||
|
return emoji;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,229 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.annotaions.Jsonable;
|
||||||
|
import hdvtdev.telegram.core.methods.util.ParseMode;
|
||||||
|
import hdvtdev.telegram.core.objects.*;
|
||||||
|
import hdvtdev.telegram.core.objects.markup.ReplyMarkup;
|
||||||
|
import hdvtdev.telegram.core.objects.message.LinkPreviewOptions;
|
||||||
|
import hdvtdev.telegram.core.objects.message.Message;
|
||||||
|
import hdvtdev.telegram.core.objects.message.MessageEntity;
|
||||||
|
|
||||||
|
|
||||||
|
@Jsonable
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public final class SendMessage implements TelegramApiMethod<Message> {
|
||||||
|
|
||||||
|
@JsonProperty("chat_id")
|
||||||
|
private final String chatId;
|
||||||
|
@JsonProperty("text")
|
||||||
|
private final String text;
|
||||||
|
@JsonProperty("business_connection_id")
|
||||||
|
private String businessConnectionId;
|
||||||
|
@JsonProperty("message_thread_id")
|
||||||
|
private Long messageThreadId;
|
||||||
|
@JsonProperty("parse_mode")
|
||||||
|
private ParseMode parseMode;
|
||||||
|
@JsonProperty("entities")
|
||||||
|
private MessageEntity[] entities;
|
||||||
|
@JsonProperty("link_preview_options")
|
||||||
|
private LinkPreviewOptions linkPreviewOptions;
|
||||||
|
@JsonProperty("disable_notification")
|
||||||
|
private Boolean disableNotification;
|
||||||
|
@JsonProperty("protect_content")
|
||||||
|
private Boolean protectContent;
|
||||||
|
@JsonProperty("allow_paid_broadcast")
|
||||||
|
private Boolean allowPaidBroadcast;
|
||||||
|
@JsonProperty("message_effect_id")
|
||||||
|
private String messageEffectId;
|
||||||
|
@JsonProperty("reply_parameters")
|
||||||
|
private ReplyParameters replyParameters;
|
||||||
|
@JsonProperty("reply_markup")
|
||||||
|
private ReplyMarkup replyMarkup;
|
||||||
|
|
||||||
|
private SendMessage(Builder builder) {
|
||||||
|
chatId = builder.chatId;
|
||||||
|
text = builder.text;
|
||||||
|
setBusinessConnectionId(builder.businessConnectionId);
|
||||||
|
setMessageThreadId(builder.messageThreadId);
|
||||||
|
setParseMode(builder.parseMode);
|
||||||
|
setEntities(builder.entities);
|
||||||
|
setLinkPreviewOptions(builder.linkPreviewOptions);
|
||||||
|
setDisableNotification(builder.disableNotification);
|
||||||
|
setProtectContent(builder.protectContent);
|
||||||
|
setAllowPaidBroadcast(builder.allowPaidBroadcast);
|
||||||
|
setMessageEffectId(builder.messageEffectId);
|
||||||
|
setReplyParameters(builder.replyParameters);
|
||||||
|
setReplyMarkup(builder.replyMarkup);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLinkPreviewOptions(LinkPreviewOptions linkPreviewOptions) {
|
||||||
|
this.linkPreviewOptions = linkPreviewOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBusinessConnectionId(String businessConnectionId) {
|
||||||
|
this.businessConnectionId = businessConnectionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageThreadId(Long messageThreadId) {
|
||||||
|
this.messageThreadId = messageThreadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParseMode(ParseMode parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntities(MessageEntity[] entities) {
|
||||||
|
this.entities = entities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisableNotification(Boolean disableNotification) {
|
||||||
|
this.disableNotification = disableNotification;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProtectContent(Boolean protectContent) {
|
||||||
|
this.protectContent = protectContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllowPaidBroadcast(Boolean allowPaidBroadcast) {
|
||||||
|
this.allowPaidBroadcast = allowPaidBroadcast;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageEffectId(String messageEffectId) {
|
||||||
|
this.messageEffectId = messageEffectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReplyParameters(ReplyParameters replyParameters) {
|
||||||
|
this.replyParameters = replyParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReplyToMessage(long messageId) {
|
||||||
|
this.replyParameters = new ReplyParameters(messageId, chatId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReplyMarkup(ReplyMarkup replyMarkup) {
|
||||||
|
this.replyMarkup = replyMarkup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendMessage(String chatId, String text) {
|
||||||
|
if (chatId.isEmpty() || text.isEmpty())
|
||||||
|
throw new IllegalArgumentException("chatId or/and message (text) cannot be empty.");
|
||||||
|
this.chatId = chatId;
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendMessage(long chatIdAsLong, String text) {
|
||||||
|
this(String.valueOf(chatIdAsLong), text);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "sendMessage";
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public Class<Message> getResponseClass() {
|
||||||
|
return Message.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private final String chatId;
|
||||||
|
private final String text;
|
||||||
|
private String businessConnectionId;
|
||||||
|
private Long messageThreadId;
|
||||||
|
private ParseMode parseMode;
|
||||||
|
private MessageEntity[] entities;
|
||||||
|
private LinkPreviewOptions linkPreviewOptions;
|
||||||
|
private Boolean disableNotification;
|
||||||
|
private Boolean protectContent;
|
||||||
|
private Boolean allowPaidBroadcast;
|
||||||
|
private String messageEffectId;
|
||||||
|
private ReplyParameters replyParameters;
|
||||||
|
private ReplyMarkup replyMarkup;
|
||||||
|
|
||||||
|
public Builder(long chatId, String text) {
|
||||||
|
this(String.valueOf(chatId), text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder(String chatId, String text) {
|
||||||
|
this.chatId = chatId;
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder businessConnectionId(String val) {
|
||||||
|
businessConnectionId = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder messageThreadId(Long val) {
|
||||||
|
messageThreadId = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder parseMode(ParseMode val) {
|
||||||
|
parseMode = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder entities(MessageEntity[] val) {
|
||||||
|
entities = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder linkPreviewOptions(LinkPreviewOptions val) {
|
||||||
|
linkPreviewOptions = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder disableNotification() {
|
||||||
|
disableNotification = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder protectContent() {
|
||||||
|
protectContent = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder allowPaidBroadcast() {
|
||||||
|
allowPaidBroadcast = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder messageEffectId(String val) {
|
||||||
|
messageEffectId = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder replyParameters(ReplyParameters val) {
|
||||||
|
replyParameters = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder replyToMessage(long val) {
|
||||||
|
replyParameters = new ReplyParameters(val, this.chatId);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder replyMarkup(ReplyMarkup val) {
|
||||||
|
replyMarkup = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendMessage build() {
|
||||||
|
return new SendMessage(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.annotaions.Jsonable;
|
||||||
|
import hdvtdev.telegram.core.objects.reaction.ReactionType;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Jsonable
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public class SetMessageReaction implements TelegramApiMethod<Boolean> {
|
||||||
|
|
||||||
|
@JsonProperty("chat_id")
|
||||||
|
private final String chatId;
|
||||||
|
@JsonProperty("message_id")
|
||||||
|
private final long messageId;
|
||||||
|
@JsonProperty("reaction")
|
||||||
|
private List<ReactionType> reactions;
|
||||||
|
@JsonProperty("is_big")
|
||||||
|
private Boolean isBig;
|
||||||
|
|
||||||
|
public SetMessageReaction(String chatId, long messageId) {
|
||||||
|
this.chatId = chatId;
|
||||||
|
this.messageId = messageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SetMessageReaction(long chatId, long messageId) {
|
||||||
|
this.chatId = String.valueOf(chatId);
|
||||||
|
this.messageId = messageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SetMessageReaction(Builder builder) {
|
||||||
|
chatId = builder.chatId;
|
||||||
|
messageId = builder.messageId;
|
||||||
|
setReactions(builder.reactions);
|
||||||
|
isBig = builder.isBig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReactions(List<ReactionType> reactions) {
|
||||||
|
this.reactions = reactions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBig(Boolean big) {
|
||||||
|
isBig = big;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "setMessageReaction";
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public Class<Boolean> getResponseClass() {
|
||||||
|
return Boolean.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private final String chatId;
|
||||||
|
private final long messageId;
|
||||||
|
private List<ReactionType> reactions;
|
||||||
|
private Boolean isBig;
|
||||||
|
|
||||||
|
public Builder(String chatId, long messageId) {
|
||||||
|
this.chatId = chatId;
|
||||||
|
this.messageId = messageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder(long chatId, long messageId) {
|
||||||
|
this.chatId = String.valueOf(chatId);
|
||||||
|
this.messageId = messageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder reactions(List<ReactionType> reactions) {
|
||||||
|
this.reactions = reactions;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder isBig(Boolean isBig) {
|
||||||
|
this.isBig = isBig;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SetMessageReaction build() {
|
||||||
|
return new SetMessageReaction(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.annotaions.Jsonable;
|
||||||
|
import hdvtdev.telegram.core.objects.command.BotCommand;
|
||||||
|
import hdvtdev.telegram.core.objects.command.BotCommandScope;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Jsonable
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public final class SetMyCommands implements TelegramApiMethod<Boolean> {
|
||||||
|
|
||||||
|
@JsonProperty("commands")
|
||||||
|
private final List<BotCommand> commands;
|
||||||
|
@JsonProperty("scope")
|
||||||
|
private Object scope;
|
||||||
|
@JsonProperty("language_code")
|
||||||
|
private String languageCode;
|
||||||
|
|
||||||
|
public SetMyCommands(List<BotCommand> commands, Object scope, String languageCode) {
|
||||||
|
this.commands = commands;
|
||||||
|
this.scope = scope;
|
||||||
|
this.languageCode = languageCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SetMyCommands(BotCommand... commands) {
|
||||||
|
this.commands = List.of(commands);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SetMyCommands(List<BotCommand> commands) {
|
||||||
|
this.commands = commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SetMyCommands(Builder builder) {
|
||||||
|
commands = builder.commands;
|
||||||
|
setScope(builder.scope);
|
||||||
|
setLanguageCode(builder.languageCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScope(Object scope) {
|
||||||
|
this.scope = scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLanguageCode(String languageCode) {
|
||||||
|
this.languageCode = languageCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "setMyCommands";
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public Class<Boolean> getResponseClass() {
|
||||||
|
return Boolean.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private final List<BotCommand> commands;
|
||||||
|
private Object scope;
|
||||||
|
private String languageCode;
|
||||||
|
|
||||||
|
public Builder(List<BotCommand> commands) {
|
||||||
|
this.commands = commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder(BotCommand... commands) {
|
||||||
|
this.commands = List.of(commands);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder scope(BotCommandScope scope) {
|
||||||
|
this.scope = scope;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder languageCode(String languageCode) {
|
||||||
|
this.languageCode = languageCode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SetMyCommands build() {
|
||||||
|
return new SetMyCommands(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to change the command's description, which is shown in the chat with the command if the chat is empty.
|
||||||
|
* Returns {@code true} on success.
|
||||||
|
* @param description New command description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.
|
||||||
|
* @param languageCode A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description.
|
||||||
|
*/
|
||||||
|
public record SetMyDescription(String description, String languageCode) implements TelegramApiMethod<Boolean> {
|
||||||
|
|
||||||
|
public SetMyDescription() {
|
||||||
|
this(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SetMyDescription(String description) {
|
||||||
|
this(description, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
if (description == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
TelegramApiMethodBody body = new TelegramApiMethodBody(2);
|
||||||
|
body.add("language_code", languageCode);
|
||||||
|
body.add("description", description);
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "setMyDescription";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<Boolean> getResponseClass() {
|
||||||
|
return Boolean.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
public record SetMyName(String name, String languageCode) implements TelegramApiMethod<Boolean> {
|
||||||
|
|
||||||
|
public SetMyName(String name) {
|
||||||
|
this(name, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TelegramApiMethodBody getBody() {
|
||||||
|
TelegramApiMethodBody body = new TelegramApiMethodBody(2);
|
||||||
|
body.add("name", this.name);
|
||||||
|
body.add("language_code", this.languageCode);
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMethodName() {
|
||||||
|
return "setMyName";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<Boolean> getResponseClass() {
|
||||||
|
return Boolean.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
public interface TelegramApiMethod<T> {
|
||||||
|
|
||||||
|
TelegramApiMethodBody getBody();
|
||||||
|
|
||||||
|
String getMethodName();
|
||||||
|
|
||||||
|
Class<T> getResponseClass();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package hdvtdev.telegram.core.methods;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public final class TelegramApiMethodBody {
|
||||||
|
|
||||||
|
private final ArrayList<Element> elements;
|
||||||
|
|
||||||
|
public TelegramApiMethodBody(int size) {
|
||||||
|
elements = new ArrayList<>(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TelegramApiMethodBody() {
|
||||||
|
elements = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(String name, String value) {
|
||||||
|
if (value != null) this.elements.add(new Element(name, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return this.elements.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Element get(int i) {
|
||||||
|
return this.elements.get(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public record Element(String name, String value) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package hdvtdev.telegram.core.methods.util;
|
||||||
|
|
||||||
|
public enum ParseMode {
|
||||||
|
MARKDOWN,
|
||||||
|
MARKDOWNV2,
|
||||||
|
HTML
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
package hdvtdev.telegram.core.methods.util;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Util {
|
||||||
|
|
||||||
|
public static void pretty(Path filePath) {
|
||||||
|
try {
|
||||||
|
if (filePath.toString().contains("InlineKeyboard")) return;
|
||||||
|
List<String> lines = Files.readAllLines(filePath);
|
||||||
|
HashSet<String> linesSet = new HashSet<>(lines);
|
||||||
|
ArrayList<String> res = new ArrayList<>(lines.size());
|
||||||
|
|
||||||
|
if (!linesSet.contains("import com.fasterxml.jackson.annotation.JsonProperty;"))
|
||||||
|
lines.add(2, "import com.fasterxml.jackson.annotation.JsonProperty;");
|
||||||
|
boolean inRecord = false;
|
||||||
|
for (String line : lines) {
|
||||||
|
if (line.contains("@JsonProperty\\(.*?\\)")) {
|
||||||
|
res.add(line);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!line.contains("@") && !line.contains("class") && !line.contains("=")) {
|
||||||
|
if (line.contains("record")) {
|
||||||
|
String bufferLine = line;
|
||||||
|
if (bufferLine.replaceAll("[{}]", "").trim().endsWith(")")) {
|
||||||
|
if (bufferLine.contains("()")) {
|
||||||
|
res.add(line);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
bufferLine = bufferLine.split("\\(", 2)[1];
|
||||||
|
bufferLine = bufferLine.split("\\)", 2)[0];
|
||||||
|
|
||||||
|
if (bufferLine.contains(",")) {
|
||||||
|
for (String element : bufferLine.split(",")) {
|
||||||
|
element = element.strip();
|
||||||
|
String ann = String.format("@JsonProperty(\"%s\") %s", element.split(" ", 2)[1], element);
|
||||||
|
line = line.replace(element, ann);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String element = bufferLine.strip();
|
||||||
|
if (element.isEmpty()) continue;
|
||||||
|
String ann = String.format("@JsonProperty(\"%s\") %s", element.split(" ", 2)[1], element);
|
||||||
|
line = line.replace(element, ann);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
inRecord = true;
|
||||||
|
res.add(line);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (inRecord) {
|
||||||
|
if (line.contains("{") && line.contains(")")) {
|
||||||
|
inRecord = false;
|
||||||
|
} else {
|
||||||
|
if (line.isEmpty() || line.contains("}")) {
|
||||||
|
res.add(line);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String element = line.strip();
|
||||||
|
if (element.isEmpty()) continue;
|
||||||
|
String ann = String.format("@JsonProperty(\"%s\") %s", element.split(" ", 2)[1].replace(",", ""), element);
|
||||||
|
line = line.replace(element, ann);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
res.add(line);
|
||||||
|
}
|
||||||
|
BufferedWriter writer = new BufferedWriter(new FileWriter(filePath.toFile()));
|
||||||
|
for (String s : res) {
|
||||||
|
writer.write(s);
|
||||||
|
writer.newLine();
|
||||||
|
}
|
||||||
|
writer.flush();
|
||||||
|
writer.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void date() {
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE; // формат ГГГГ-ММ-ДД
|
||||||
|
|
||||||
|
String formattedDate = today.format(formatter);
|
||||||
|
System.out.println(formattedDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChosenInlineResult(
|
||||||
|
@JsonProperty("result_id") String resultId,
|
||||||
|
@JsonProperty("from") User from,
|
||||||
|
@JsonProperty("location") Location location,
|
||||||
|
@JsonProperty("inline_message_id") String inlineMessageId,
|
||||||
|
@JsonProperty("query") String query
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record Contact(
|
||||||
|
@JsonProperty("phone_number") String phoneNumber,
|
||||||
|
@JsonProperty("first_name") String firstName,
|
||||||
|
@JsonProperty("last_name") String lastName,
|
||||||
|
@JsonProperty("user_id") long userId,
|
||||||
|
@JsonProperty("vcard") String vcard
|
||||||
|
) {
|
||||||
|
}
|
||||||
13
core/src/main/java/hdvtdev/telegram/core/objects/Dice.java
Normal file
13
core/src/main/java/hdvtdev/telegram/core/objects/Dice.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record Dice(
|
||||||
|
@JsonProperty("emoji") String emoji,
|
||||||
|
@JsonProperty("value") int value
|
||||||
|
) {
|
||||||
|
}
|
||||||
20
core/src/main/java/hdvtdev/telegram/core/objects/Game.java
Normal file
20
core/src/main/java/hdvtdev/telegram/core/objects/Game.java
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.media.Animation;
|
||||||
|
import hdvtdev.telegram.core.objects.media.PhotoSize;
|
||||||
|
import hdvtdev.telegram.core.objects.message.MessageEntity;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record Game(
|
||||||
|
@JsonProperty("title") String title,
|
||||||
|
@JsonProperty("description") String description,
|
||||||
|
@JsonProperty("photo") PhotoSize[] photo,
|
||||||
|
@JsonProperty("text") String text,
|
||||||
|
@JsonProperty("text_entities") MessageEntity[] textEntities,
|
||||||
|
@JsonProperty("animation") Animation animation
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record InlineQuery(
|
||||||
|
@JsonProperty("id") String id,
|
||||||
|
@JsonProperty("from") User from,
|
||||||
|
@JsonProperty("query") String query,
|
||||||
|
@JsonProperty("offset") String offset,
|
||||||
|
@JsonProperty("chat_type") String chatType,
|
||||||
|
@JsonProperty("location") Location location
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record Location(
|
||||||
|
@JsonProperty("latitude") float latitude,
|
||||||
|
@JsonProperty("longitude") float longitude,
|
||||||
|
@JsonProperty("horizontal_accuracy") float horizontalAccuracy,
|
||||||
|
@JsonProperty("live_period") int livePeriod,
|
||||||
|
@JsonProperty("heading") int heading,
|
||||||
|
@JsonProperty("proximity_alert_radius") int proximityAlertRadius
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record LoginUrl(
|
||||||
|
@JsonProperty("url") String url,
|
||||||
|
@JsonProperty("forward_text") String forwardText,
|
||||||
|
@JsonProperty("bot_username") String botUsername,
|
||||||
|
@JsonProperty("request_write_access") boolean requestWriteAccess
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record MaskPosition(
|
||||||
|
@JsonProperty("point") String point,
|
||||||
|
@JsonProperty("x_shift") float xShift,
|
||||||
|
@JsonProperty("y_shift") float yShift,
|
||||||
|
@JsonProperty("scale") float scale
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ProximityAlertTriggered(
|
||||||
|
@JsonProperty("traveler") User traveler,
|
||||||
|
@JsonProperty("watcher") User watcher,
|
||||||
|
@JsonProperty("distance") int distance
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.message.MessageEntity;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ReplyParameters(
|
||||||
|
@JsonProperty("message_id") long messageId,
|
||||||
|
@JsonProperty("chat_id") String chatId,
|
||||||
|
@JsonProperty("allow_sending_without_reply") boolean allowSendingWithoutReply,
|
||||||
|
@JsonProperty("quote") String quote,
|
||||||
|
@JsonProperty("quote_parse_mode") String quoteParseMode,
|
||||||
|
@JsonProperty("quote_entities") MessageEntity[] quoteEntities,
|
||||||
|
@JsonProperty("quote_position") Integer quotePosition
|
||||||
|
) {
|
||||||
|
|
||||||
|
public ReplyParameters(long messageId, String chatId) {
|
||||||
|
this(messageId, chatId, false, null, null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReplyParameters(long messageId, long chatId) {
|
||||||
|
this(messageId, String.valueOf(chatId));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.media.PhotoSize;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record SharedUser(
|
||||||
|
@JsonProperty("user_id") long userId,
|
||||||
|
@JsonProperty("first_name") String firstName,
|
||||||
|
@JsonProperty("last_name") String lastName,
|
||||||
|
@JsonProperty("username") String username,
|
||||||
|
@JsonProperty("photo") PhotoSize[] photo
|
||||||
|
) {
|
||||||
|
}
|
||||||
154
core/src/main/java/hdvtdev/telegram/core/objects/Update.java
Normal file
154
core/src/main/java/hdvtdev/telegram/core/objects/Update.java
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.business.BusinessConnection;
|
||||||
|
import hdvtdev.telegram.core.objects.business.BusinessMessagesDeleted;
|
||||||
|
import hdvtdev.telegram.core.objects.callback.CallbackQuery;
|
||||||
|
import hdvtdev.telegram.core.objects.chat.ChatJoinRequest;
|
||||||
|
import hdvtdev.telegram.core.objects.chat.ChatMemberUpdated;
|
||||||
|
import hdvtdev.telegram.core.objects.chatboost.ChatBoostRemoved;
|
||||||
|
import hdvtdev.telegram.core.objects.chatboost.ChatBoostUpdated;
|
||||||
|
import hdvtdev.telegram.core.objects.media.paidmedia.PaidMediaPurchased;
|
||||||
|
import hdvtdev.telegram.core.objects.message.Message;
|
||||||
|
import hdvtdev.telegram.core.objects.message.MessageReactionCountUpdated;
|
||||||
|
import hdvtdev.telegram.core.objects.message.MessageReactionUpdated;
|
||||||
|
import hdvtdev.telegram.core.objects.payment.PreCheckoutQuery;
|
||||||
|
import hdvtdev.telegram.core.objects.payment.ShippingQuery;
|
||||||
|
import hdvtdev.telegram.core.objects.poll.Poll;
|
||||||
|
import hdvtdev.telegram.core.objects.poll.PollAnswer;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record Update(
|
||||||
|
@JsonProperty("update_id") long updateId,
|
||||||
|
@JsonProperty("message") Message message,
|
||||||
|
@JsonProperty("edited_message") Message editedMessage,
|
||||||
|
@JsonProperty("channel_post") Message channelPost,
|
||||||
|
@JsonProperty("edited_channel_post") Message editedChannelPost,
|
||||||
|
@JsonProperty("business_connection") BusinessConnection businessConnection,
|
||||||
|
@JsonProperty("business_message") Message businessMessage,
|
||||||
|
@JsonProperty("edited_business_message") Message editedBusinessMessage,
|
||||||
|
@JsonProperty("deleted_business_messages") BusinessMessagesDeleted businessMessagesDeleted,
|
||||||
|
@JsonProperty("message_reaction") MessageReactionUpdated messageReaction,
|
||||||
|
@JsonProperty("message_reaction_count") MessageReactionCountUpdated messageReactionCount,
|
||||||
|
@JsonProperty("inline_query") InlineQuery inlineQuery,
|
||||||
|
@JsonProperty("chosen_inline_result") ChosenInlineResult chosenInlineResult,
|
||||||
|
@JsonProperty("callback_query") CallbackQuery callbackQuery,
|
||||||
|
@JsonProperty("shipping_query") ShippingQuery shippingQuery,
|
||||||
|
@JsonProperty("pre_checkout_query") PreCheckoutQuery preCheckoutQuery,
|
||||||
|
@JsonProperty("purchased_paid_media") PaidMediaPurchased paidMediaPurchased,
|
||||||
|
@JsonProperty("poll") Poll poll,
|
||||||
|
@JsonProperty("poll_answer") PollAnswer pollAnswer,
|
||||||
|
@JsonProperty("my_chat_member") ChatMemberUpdated myChatMember,
|
||||||
|
@JsonProperty("chat_member") ChatMemberUpdated chatMember,
|
||||||
|
@JsonProperty("chat_join_request") ChatJoinRequest chatJoinRequest,
|
||||||
|
@JsonProperty("chat_boost") ChatBoostUpdated chatBoost,
|
||||||
|
@JsonProperty("removed_chat_boost") ChatBoostRemoved chatBoostRemoved
|
||||||
|
) {
|
||||||
|
|
||||||
|
public boolean hasMessage() {
|
||||||
|
return this.message != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasEditedMessage() {
|
||||||
|
return this.editedMessage != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasChannelPost() {
|
||||||
|
return this.channelPost != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasEditedChannelPost() {
|
||||||
|
return this.editedChannelPost != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasBusinessConnection() {
|
||||||
|
return this.businessConnection != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasBusinessMessage() {
|
||||||
|
return this.businessMessage != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasEditedBusinessMessage() {
|
||||||
|
return this.editedBusinessMessage != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasDeletedBusinessMessages() {
|
||||||
|
return this.businessMessagesDeleted != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasMessageReaction() {
|
||||||
|
return this.messageReaction != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasMessageReactionCount() {
|
||||||
|
return this.messageReactionCount != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasInlineQuery() {
|
||||||
|
return this.inlineQuery != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasChosenInlineResult() {
|
||||||
|
return this.chosenInlineResult != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasCallbackQuery() {
|
||||||
|
return this.callbackQuery != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasShippingQuery() {
|
||||||
|
return this.shippingQuery != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPreCheckoutQuery() {
|
||||||
|
return this.preCheckoutQuery != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPurchasedPaidMedia() {
|
||||||
|
return this.paidMediaPurchased != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPoll() {
|
||||||
|
return this.poll != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPollAnswer() {
|
||||||
|
return this.pollAnswer != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasMyChatMember() {
|
||||||
|
return this.myChatMember != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasChatMember() {
|
||||||
|
return this.chatMember != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasChatJoinRequest() {
|
||||||
|
return this.chatJoinRequest != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasChatBoost() {
|
||||||
|
return this.chatBoost != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasRemovedChatBoost() {
|
||||||
|
return this.chatBoostRemoved != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<String> getAnyText() {
|
||||||
|
if (hasMessage()) {
|
||||||
|
if (message.hasText()) return Optional.of(message.text());
|
||||||
|
if (message.hasCaption()) return Optional.of(message.caption());
|
||||||
|
}
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
62
core/src/main/java/hdvtdev/telegram/core/objects/User.java
Normal file
62
core/src/main/java/hdvtdev/telegram/core/objects/User.java
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record User(
|
||||||
|
@JsonProperty("id") long id,
|
||||||
|
@JsonProperty("is_bot") boolean isBot,
|
||||||
|
@JsonProperty("first_name") String firstName,
|
||||||
|
@JsonProperty("last_name") String lastName,
|
||||||
|
@JsonProperty("username") String username,
|
||||||
|
@JsonProperty("language_code") String languageCode,
|
||||||
|
@JsonProperty("is_premium") boolean isPremium,
|
||||||
|
@JsonProperty("added_to_attachment_menu") boolean addedToAttachmentMenu
|
||||||
|
) {
|
||||||
|
|
||||||
|
public boolean hasLastName() {
|
||||||
|
return this.lastName != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasUsername() {
|
||||||
|
return this.username != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasLanguageCode() {
|
||||||
|
return this.languageCode != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public record Bot(
|
||||||
|
@JsonProperty("id") long id,
|
||||||
|
@JsonProperty("is_bot") Boolean isBot,
|
||||||
|
@JsonProperty("first_name") String firstName,
|
||||||
|
@JsonProperty("last_name") String lastName,
|
||||||
|
@JsonProperty("username") String username,
|
||||||
|
@JsonProperty("language_code") String languageCode,
|
||||||
|
@JsonProperty("is_premium") boolean isPremium,
|
||||||
|
@JsonProperty("added_to_attachment_menu") boolean addedToAttachmentMenu,
|
||||||
|
@JsonProperty("can_join_groups") boolean canJoinGroups,
|
||||||
|
@JsonProperty("can_read_all_group_messages") boolean canReadAllGroupMessages,
|
||||||
|
@JsonProperty("supports_inline_queries") boolean supportsInlineQueries,
|
||||||
|
@JsonProperty("can_connect_to_business") boolean canConnectToBusiness,
|
||||||
|
@JsonProperty("has_main_web_app") boolean hasMainWebApp
|
||||||
|
) {
|
||||||
|
|
||||||
|
public boolean hasLastName() {
|
||||||
|
return this.lastName != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasUsername() {
|
||||||
|
return this.username != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasLanguageCode() {
|
||||||
|
return this.languageCode != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record UsersShared(
|
||||||
|
@JsonProperty("request_id") int requestId,
|
||||||
|
@JsonProperty("users") SharedUser[] users
|
||||||
|
) {
|
||||||
|
}
|
||||||
18
core/src/main/java/hdvtdev/telegram/core/objects/Venue.java
Normal file
18
core/src/main/java/hdvtdev/telegram/core/objects/Venue.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record Venue(
|
||||||
|
@JsonProperty("location") Location location,
|
||||||
|
@JsonProperty("title") String title,
|
||||||
|
@JsonProperty("address") String address,
|
||||||
|
@JsonProperty("foursquare_id") String foursquareId,
|
||||||
|
@JsonProperty("foursquare_type") String foursquareType,
|
||||||
|
@JsonProperty("google_place_id") String googlePlaceId,
|
||||||
|
@JsonProperty("google_place_type") String googlePlaceType
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record WebAppData(String data, @JsonProperty("button_text") String buttonText) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record WebAppInfo(@JsonProperty("url") String url) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package hdvtdev.telegram.core.objects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record WriteAccessAllowed(
|
||||||
|
@JsonProperty("from_request") boolean fromRequest,
|
||||||
|
@JsonProperty("web_app_name") String webAppName,
|
||||||
|
@JsonProperty("from_attachment_menu") boolean fromAttachmentMenu
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.background;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||||
|
|
||||||
|
@JsonTypeInfo(
|
||||||
|
use = JsonTypeInfo.Id.NAME,
|
||||||
|
include = JsonTypeInfo.As.EXISTING_PROPERTY,
|
||||||
|
property = "type"
|
||||||
|
)
|
||||||
|
@JsonSubTypes({
|
||||||
|
@JsonSubTypes.Type(value = BackgroundFillSolid.class, name = "solid"),
|
||||||
|
@JsonSubTypes.Type(value = BackgroundFillGradient.class, name = "gradient"),
|
||||||
|
@JsonSubTypes.Type(value = BackgroundFillFreeformGradient.class, name = "freeform_gradient")
|
||||||
|
})
|
||||||
|
public interface BackgroundFill {
|
||||||
|
String type();
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.background;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
|
import com.fasterxml.jackson.core.ObjectCodec;
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
|
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public final class BackgroundFillDeserializer extends JsonDeserializer<BackgroundFill> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BackgroundFill deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException {
|
||||||
|
ObjectCodec codec = parser.getCodec();
|
||||||
|
JsonNode node = codec.readTree(parser);
|
||||||
|
|
||||||
|
String type = node.get("type").asText();
|
||||||
|
|
||||||
|
return switch (type) {
|
||||||
|
case "solid" -> codec.treeToValue(node, BackgroundFillSolid.class);
|
||||||
|
case "gradient" -> codec.treeToValue(node, BackgroundFillGradient.class);
|
||||||
|
case "freeform_gradient" -> codec.treeToValue(node, BackgroundFillFreeformGradient.class);
|
||||||
|
default -> throw new IllegalArgumentException("Unknown type: " + type);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.background;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record BackgroundFillFreeformGradient(
|
||||||
|
@JsonProperty("type") String type,
|
||||||
|
@JsonProperty("colors") int[] colors
|
||||||
|
) implements BackgroundFill {
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.background;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record BackgroundFillGradient(
|
||||||
|
@JsonProperty("type") String type,
|
||||||
|
@JsonProperty("top_color") int topColor,
|
||||||
|
@JsonProperty("bottom_color") int bottomColor,
|
||||||
|
@JsonProperty("rotation_angle") int rotationAngle
|
||||||
|
) implements BackgroundFill {
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.background;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record BackgroundFillSolid(
|
||||||
|
@JsonProperty("type") String type,
|
||||||
|
@JsonProperty("color") int color
|
||||||
|
) implements BackgroundFill {
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.background;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
|
||||||
|
@JsonDeserialize(using = BackgroundTypeDeserializer.class)
|
||||||
|
public interface BackgroundType {
|
||||||
|
String type();
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.background;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record BackgroundTypeChatTheme(
|
||||||
|
@JsonProperty("type") String type,
|
||||||
|
@JsonProperty("theme_name") String themeName
|
||||||
|
) implements BackgroundType {
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.background;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
|
import com.fasterxml.jackson.core.ObjectCodec;
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
|
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public final class BackgroundTypeDeserializer extends JsonDeserializer<BackgroundType> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BackgroundType deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException {
|
||||||
|
ObjectCodec codec = parser.getCodec();
|
||||||
|
JsonNode node = codec.readTree(parser);
|
||||||
|
|
||||||
|
String type = node.get("type").asText();
|
||||||
|
|
||||||
|
return switch (type) {
|
||||||
|
case "fill" -> codec.treeToValue(node, BackgroundTypeFill.class);
|
||||||
|
case "wallpaper" -> codec.treeToValue(node, BackgroundTypeWallpaper.class);
|
||||||
|
case "pattern" -> codec.treeToValue(node, BackgroundTypePattern.class);
|
||||||
|
case "chat_theme" -> codec.treeToValue(node, BackgroundTypeChatTheme.class);
|
||||||
|
default -> throw new IllegalArgumentException("Unknown type: " + type);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.background;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record BackgroundTypeFill(
|
||||||
|
@JsonProperty("type") String type,
|
||||||
|
@JsonProperty("fill") BackgroundFill fill,
|
||||||
|
@JsonProperty("dark_theme_dimming") int darkThemeDimming
|
||||||
|
) implements BackgroundType {
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.background;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.media.Document;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record BackgroundTypePattern(
|
||||||
|
@JsonProperty("type") String type,
|
||||||
|
@JsonProperty("document") Document document,
|
||||||
|
@JsonProperty("fill") BackgroundFill fill,
|
||||||
|
@JsonProperty("is_inverted") boolean isInverted,
|
||||||
|
@JsonProperty("is_moving") boolean isMoving
|
||||||
|
) implements BackgroundType {
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.background;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.media.Document;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record BackgroundTypeWallpaper(
|
||||||
|
@JsonProperty("type") String type,
|
||||||
|
@JsonProperty("document") Document document,
|
||||||
|
@JsonProperty("dark_theme_dimming") int darkThemeDimming,
|
||||||
|
@JsonProperty("is_blurred") boolean isBlurred,
|
||||||
|
@JsonProperty("is_moving") boolean isMoving
|
||||||
|
) implements BackgroundType {
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.business;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.User;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record BusinessConnection(
|
||||||
|
@JsonProperty("id") String id,
|
||||||
|
@JsonProperty("user") User user,
|
||||||
|
@JsonProperty("user_chat_id") long userChatId,
|
||||||
|
@JsonProperty("date") long date,
|
||||||
|
@JsonProperty("can_reply") boolean canReply,
|
||||||
|
@JsonProperty("is_enabled") boolean isEnabled
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.business;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.chat.Chat;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record BusinessMessagesDeleted(
|
||||||
|
@JsonProperty("business_connection_id") String businessConnectionId,
|
||||||
|
@JsonProperty("chat") Chat chat,
|
||||||
|
@JsonProperty("message_ids") long[] messageIds
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.callback;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record CallbackGame() {
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.callback;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.User;
|
||||||
|
import hdvtdev.telegram.core.objects.message.MaybeInaccessibleMessage;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record CallbackQuery(
|
||||||
|
@JsonProperty("id") String id,
|
||||||
|
@JsonProperty("from") User from,
|
||||||
|
@JsonProperty("message") MaybeInaccessibleMessage message,
|
||||||
|
@JsonProperty("inline_message_id") String inlineMessageId,
|
||||||
|
@JsonProperty("chat_instance") String chatInstance,
|
||||||
|
@JsonProperty("data") String data,
|
||||||
|
@JsonProperty("game_short_name") String gameShortName
|
||||||
|
) {
|
||||||
|
|
||||||
|
public boolean hasMessage() {
|
||||||
|
return this.message != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasInlineMessageId() {
|
||||||
|
return this.inlineMessageId != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasChatInstance() {
|
||||||
|
return this.chatInstance != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasData() {
|
||||||
|
return this.data != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasGameShortName() {
|
||||||
|
return this.gameShortName != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chat;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record Chat(
|
||||||
|
@JsonProperty("id") long id,
|
||||||
|
@JsonProperty("type") String type,
|
||||||
|
@JsonProperty("title") String title,
|
||||||
|
@JsonProperty("username") String username,
|
||||||
|
@JsonProperty("first_name") String firstName,
|
||||||
|
@JsonProperty("last_name") String lastName,
|
||||||
|
@JsonProperty("is_forum") boolean isForum
|
||||||
|
) {
|
||||||
|
|
||||||
|
public boolean hasTitle() {
|
||||||
|
return this.title != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasUsername() {
|
||||||
|
return this.username != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasFirstName() {
|
||||||
|
return this.firstName != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasLastName() {
|
||||||
|
return this.lastName != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chat;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatAdministratorRights(
|
||||||
|
@JsonProperty("is_anonymous") boolean isAnonymous,
|
||||||
|
@JsonProperty("can_manage_chat") boolean canManageChat,
|
||||||
|
@JsonProperty("can_delete_messages") boolean canDeleteMessages,
|
||||||
|
@JsonProperty("can_manage_video_chats") boolean canManageVideoChats,
|
||||||
|
@JsonProperty("can_restrict_members") boolean canRestrictMembers,
|
||||||
|
@JsonProperty("can_promote_members") boolean canPromoteMembers,
|
||||||
|
@JsonProperty("can_change_info") boolean canChangeInfo,
|
||||||
|
@JsonProperty("can_invite_users") boolean canInviteUsers,
|
||||||
|
@JsonProperty("can_post_stories") boolean canPostStories,
|
||||||
|
@JsonProperty("can_edit_stories") boolean canEditStories,
|
||||||
|
@JsonProperty("can_delete_stories") boolean canDeleteStories,
|
||||||
|
@JsonProperty("can_post_messages") boolean canPostMessages,
|
||||||
|
@JsonProperty("can_edit_messages") boolean canEditMessages,
|
||||||
|
@JsonProperty("can_pin_messages") boolean canPinMessages,
|
||||||
|
@JsonProperty("can_manage_topics") boolean canManageTopics
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chat;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.objects.background.BackgroundType;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatBackground(@JsonProperty("type") BackgroundType type) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chat;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import hdvtdev.telegram.core.objects.User;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatInviteLink(
|
||||||
|
@JsonProperty("invite_link") String inviteLink,
|
||||||
|
@JsonProperty("creator") User creator,
|
||||||
|
@JsonProperty("creates_join_request") boolean createsJoinRequest,
|
||||||
|
@JsonProperty("is_primary") boolean isPrimary,
|
||||||
|
@JsonProperty("is_revoked") boolean isRevoked,
|
||||||
|
@JsonProperty("name") String name,
|
||||||
|
@JsonProperty("expire_date") long expireDate,
|
||||||
|
@JsonProperty("member_limit") int memberLimit,
|
||||||
|
@JsonProperty("pending_join_request_count") int pendingJoinRequestCount,
|
||||||
|
@JsonProperty("subscription_period") int subscriptionPeriod,
|
||||||
|
@JsonProperty("subscription_price") int subscriptionPrice
|
||||||
|
) {
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.inviteLink;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chat;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.User;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatJoinRequest(
|
||||||
|
@JsonProperty("chat") Chat chat,
|
||||||
|
@JsonProperty("from") User from,
|
||||||
|
@JsonProperty("user_chat_id") long userChatId,
|
||||||
|
@JsonProperty("date") long date,
|
||||||
|
@JsonProperty("bio") String bio,
|
||||||
|
@JsonProperty("invite_link") ChatInviteLink chatInviteLink
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chat;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||||
|
import hdvtdev.telegram.core.objects.User;
|
||||||
|
|
||||||
|
@JsonTypeInfo(
|
||||||
|
use = JsonTypeInfo.Id.NAME,
|
||||||
|
include = JsonTypeInfo.As.EXISTING_PROPERTY,
|
||||||
|
property = "status"
|
||||||
|
)
|
||||||
|
@JsonSubTypes({
|
||||||
|
@JsonSubTypes.Type(value = ChatMemberAdministrator.class, name = "administrator"),
|
||||||
|
@JsonSubTypes.Type(value = ChatMemberBanned.class, name = "kicked"),
|
||||||
|
@JsonSubTypes.Type(value = ChatMemberLeft.class, name = "left"),
|
||||||
|
@JsonSubTypes.Type(value = ChatMemberMember.class, name = "member"),
|
||||||
|
@JsonSubTypes.Type(value = ChatMemberOwner.class, name = "creator"),
|
||||||
|
@JsonSubTypes.Type(value = ChatMemberRestricted.class, name = "restricted"),
|
||||||
|
})
|
||||||
|
public interface ChatMember {
|
||||||
|
User user();
|
||||||
|
String status();
|
||||||
|
|
||||||
|
default ChatMemberAdministrator getAsChatMemberAdministrator() {
|
||||||
|
return (ChatMemberAdministrator) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chat;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.User;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatMemberAdministrator(
|
||||||
|
@JsonProperty("status") String status,
|
||||||
|
@JsonProperty("user") User user,
|
||||||
|
@JsonProperty("can_be_edited") boolean canBeEdited,
|
||||||
|
@JsonProperty("is_anonymous") boolean isAnonymous,
|
||||||
|
@JsonProperty("can_manage_chat") boolean canManageChat,
|
||||||
|
@JsonProperty("can_delete_messages") boolean canDeleteMessages,
|
||||||
|
@JsonProperty("can_manage_video_chats") boolean canManageVideoChat,
|
||||||
|
@JsonProperty("can_restrict_members") boolean canRestrictMembers,
|
||||||
|
@JsonProperty("can_promote_members") boolean canPromoteMembers,
|
||||||
|
@JsonProperty("can_change_info") boolean canChangeInfo,
|
||||||
|
@JsonProperty("can_invite_users") boolean canInviteUsers,
|
||||||
|
@JsonProperty("can_post_stories") boolean canPostStories,
|
||||||
|
@JsonProperty("can_edit_stories") boolean canEditStories,
|
||||||
|
@JsonProperty("can_delete_stories") boolean canDeleteStories,
|
||||||
|
@JsonProperty("can_post_messages") boolean canPostMessages,
|
||||||
|
@JsonProperty("can_edit_messages") boolean canEditMessages,
|
||||||
|
@JsonProperty("can_pin_messages") boolean canPinMessages,
|
||||||
|
@JsonProperty("can_manage_topics") boolean canManageTopics,
|
||||||
|
@JsonProperty("custom_title") boolean hasCustomTitle
|
||||||
|
) implements ChatMember {
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chat;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.User;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatMemberBanned(
|
||||||
|
@JsonProperty("status") String status,
|
||||||
|
@JsonProperty("user") User user,
|
||||||
|
@JsonProperty("until_date") long untilDate
|
||||||
|
) implements ChatMember {
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chat;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.User;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatMemberLeft(
|
||||||
|
@JsonProperty("status") String status,
|
||||||
|
@JsonProperty("user") User user
|
||||||
|
) implements ChatMember {
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chat;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.User;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatMemberMember(
|
||||||
|
@JsonProperty("status") String status,
|
||||||
|
@JsonProperty("user") User user,
|
||||||
|
@JsonProperty("until_date") long untilDate
|
||||||
|
) implements ChatMember {
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chat;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.User;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatMemberOwner(
|
||||||
|
@JsonProperty("status") String status,
|
||||||
|
@JsonProperty("user") User user,
|
||||||
|
@JsonProperty("is_anonymous") boolean isAnonymous,
|
||||||
|
@JsonProperty("custom_title") String customTitle
|
||||||
|
) implements ChatMember {
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chat;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.User;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatMemberRestricted(
|
||||||
|
@JsonProperty("status") String status,
|
||||||
|
@JsonProperty("user") User user,
|
||||||
|
@JsonProperty("is_member") boolean isMember,
|
||||||
|
@JsonProperty("can_send_messages") boolean canSendMessage,
|
||||||
|
@JsonProperty("can_send_audios") boolean canSendAudios,
|
||||||
|
@JsonProperty("can_send_documents") boolean canSendDocuments,
|
||||||
|
@JsonProperty("can_send_photos") boolean canSendPhotos,
|
||||||
|
@JsonProperty("can_send_videos") boolean canSendVideos,
|
||||||
|
@JsonProperty("can_send_video_notes") boolean canSendVideoNotes,
|
||||||
|
@JsonProperty("can_send_voice_notes") boolean canSendVoiceNotes,
|
||||||
|
@JsonProperty("can_send_polls") boolean canSendPolls,
|
||||||
|
@JsonProperty("can_send_other_messages") boolean canSendOtherMessages,
|
||||||
|
@JsonProperty("can_add_web_page_previews") boolean canAddWebPagePreviews,
|
||||||
|
@JsonProperty("can_change_info") boolean canChangeInfo,
|
||||||
|
@JsonProperty("can_invite_users") boolean canInviteUsers,
|
||||||
|
@JsonProperty("can_pin_messages") boolean canPinMessages,
|
||||||
|
@JsonProperty("can_manage_topics") boolean canManageTopics,
|
||||||
|
@JsonProperty("until_date") long untilDate
|
||||||
|
) implements ChatMember {
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chat;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.User;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatMemberUpdated(
|
||||||
|
@JsonProperty("chat") Chat chat,
|
||||||
|
@JsonProperty("from") User from,
|
||||||
|
@JsonProperty("date") long date,
|
||||||
|
@JsonProperty("old_chat_member") ChatMember oldChatMember,
|
||||||
|
@JsonProperty("new_chat_member") ChatMember newChatMember,
|
||||||
|
@JsonProperty("invite_link") ChatInviteLink chatInviteLink,
|
||||||
|
@JsonProperty("via_join_request") boolean viaJoinRequest,
|
||||||
|
@JsonProperty("via_chat_folder_invite_link") boolean viaChatFolderInviteLink
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chat;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.media.PhotoSize;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatShared(
|
||||||
|
@JsonProperty("request_id") int requestId,
|
||||||
|
@JsonProperty("chat_id") long chatId,
|
||||||
|
@JsonProperty("title") String title,
|
||||||
|
@JsonProperty("username") String username,
|
||||||
|
@JsonProperty("photo") PhotoSize[] photo
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chatboost;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatBoost(
|
||||||
|
@JsonProperty("boost_id") String boostId,
|
||||||
|
@JsonProperty("add_date") long addDate,
|
||||||
|
@JsonProperty("expiration_date") long expirationDate,
|
||||||
|
@JsonProperty("source") ChatBoostSource source
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chatboost;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatBoostAdded(
|
||||||
|
@JsonProperty("boost_count") int boostCount
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chatboost;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.chat.Chat;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatBoostRemoved(
|
||||||
|
@JsonProperty("chat") Chat chat,
|
||||||
|
@JsonProperty("boost_id") String boostId,
|
||||||
|
@JsonProperty("remove_date") long removeDate,
|
||||||
|
@JsonProperty("source") ChatBoostSource source
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chatboost;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||||
|
|
||||||
|
@JsonTypeInfo(
|
||||||
|
use = JsonTypeInfo.Id.NAME,
|
||||||
|
include = JsonTypeInfo.As.EXISTING_PROPERTY,
|
||||||
|
property = "source"
|
||||||
|
)
|
||||||
|
@JsonSubTypes({
|
||||||
|
@JsonSubTypes.Type(value = ChatBoostSourcePremium.class, name = "premium"),
|
||||||
|
@JsonSubTypes.Type(value = ChatBoostSourceGiveaway.class, name = "giveaway"),
|
||||||
|
@JsonSubTypes.Type(value = ChatBoostSourceGiftCode.class, name = "gift_code")
|
||||||
|
})
|
||||||
|
public interface ChatBoostSource {
|
||||||
|
String source();
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chatboost;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.User;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatBoostSourceGiftCode(
|
||||||
|
@JsonProperty("source") String source,
|
||||||
|
@JsonProperty("user") User user
|
||||||
|
) implements ChatBoostSource {
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chatboost;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.User;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatBoostSourceGiveaway(
|
||||||
|
@JsonProperty("source") String source,
|
||||||
|
@JsonProperty("giveaway_message_id") long giveawayMessageId,
|
||||||
|
@JsonProperty("user") User user,
|
||||||
|
@JsonProperty("prize_star_count") int prizeStarCount,
|
||||||
|
@JsonProperty("is_unclaimed") boolean isUnclaimed
|
||||||
|
) implements ChatBoostSource {
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chatboost;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.User;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatBoostSourcePremium(
|
||||||
|
@JsonProperty("source") String source,
|
||||||
|
@JsonProperty("user") User user
|
||||||
|
) implements ChatBoostSource {
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package hdvtdev.telegram.core.objects.chatboost;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import hdvtdev.telegram.core.objects.chat.Chat;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public record ChatBoostUpdated(
|
||||||
|
@JsonProperty("chat") Chat chat,
|
||||||
|
@JsonProperty("boost") ChatBoost boost
|
||||||
|
) {
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user