some refactoring

This commit is contained in:
hdvtdev
2025-04-22 12:37:13 +03:00
parent 7b66404e3e
commit 111eafdc0a
379 changed files with 592 additions and 8633 deletions

View File

@@ -1,55 +0,0 @@
package hdvtdev.telegram;
import com.fasterxml.jackson.databind.ObjectMapper;
import hdvtdev.telegram.annotations.handlers.TextMessageHandler;
import hdvtdev.telegram.core.OkHttpTelegramBot;
import hdvtdev.telegram.core.TelegramBot;
import hdvtdev.telegram.core.UpdateConsumer;
import hdvtdev.telegram.exceptions.TelegramApiException;
import hdvtdev.telegram.methods.*;
import hdvtdev.telegram.objects.*;
import hdvtdev.telegram.util.ClassFinder;
import java.util.Arrays;
import java.util.List;
public class Main {
private static String apiKey;
private static long idd = 2027845508;
public static TelegramBot bot;
@TextMessageHandler("пинг")
private static void ping(Message message) {
bot.execute(new SendMessage(message.chatId(), String.valueOf(bot.getPing())));
}
public static void main(String[] args) throws Exception {
bot = new OkHttpTelegramBot.Builder(args[0]).enableHandlers(true).build();
bot.enableDefaultUpdateConsumer();
apiKey = args[2];
}
private static class Upd implements UpdateConsumer, ClassFinder.ErrorHandler {
@Override
public void onError(Throwable throwable) {
throwable.printStackTrace();
}
@Override
public void getUpdates(List<Update> updates) {
updates.forEach(System.out::println);
}
}
}

View File

@@ -1,58 +0,0 @@
package hdvtdev.telegram.annotations.handlers;
import hdvtdev.telegram.objects.CallbackQuery;
import hdvtdev.telegram.objects.Update;
import org.jetbrains.annotations.NotNull;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Marks a static method as a handler for {@link CallbackQuery} updates with specific data values.
* <p>
* If {@code value} is set to "*", the method will handle all {@link CallbackQuery} data,
* and other {@code @CallbackQueryHandler} methods will be ignored.
* <p>
* The annotated method must be {@code static} and may accept:
* <ul>
* <li>{@link Void} {@code (no params)}</li>
* <li>{@link Update}</li>
* <li>{@link CallbackQuery}</li>
* </ul>
* Only one parameter is allowed.
* <p>
* You do not need to call {@link CallbackQuery#hasData()} or {@link Update#hasCallbackQuery()},
* as these checks are performed automatically before invocation.
*
* <h3>Usage example:</h3>
* <pre><code>
* {@code @CallbackQueryHandler({"stop",} "shutdown"})
* private static void stop(CallbackQuery callbackQuery) {
* long id = callbackQuery.message.chatId;
* if (DatabaseManager.isAdmin(id)) {
* bot.awaitExecute(new SendMessage(id, "Shutting down..."));
* System.exit(0);
* }
* }
* </code></pre>
* <h5>Last documentation update: 2025-04-05</h5>
* @see Update
* @see CallbackQuery
* @since 1.0.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface CallbackQueryHandler {
/**
* Values to match against {@link CallbackQuery#data()}.
* If set to "*", this method will handle all {@link CallbackQuery} updates,
* overriding any other {@code @CallbackQueryHandler} annotations.
*
* @return array of matching strings
*/
@NotNull String[] value() default "*";
}

View File

@@ -1,61 +0,0 @@
package hdvtdev.telegram.annotations.handlers;
import hdvtdev.telegram.objects.Message;
import hdvtdev.telegram.objects.Update;
import org.jetbrains.annotations.NotNull;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Marks a static method as a handler for {@link Message} updates with specific data values.
* <p>
* If {@code value} is set to "*", the method will handle all {@link Message} text,
* and other {@code @TextMessageHandler} methods will be ignored.
* <p>
* The annotated method must be {@code static} and may accept:
* <ul>
* <li>{@link Void} {@code (no params)}</li>
* <li>{@link Update}</li>
* <li>{@link Message}</li>
* </ul>
* Only one parameter is allowed.
* <p>
* You do not need to call {@link Message#hasText()} or {@link Update#hasMessage()},
* as these checks are performed automatically before invocation.
*
* <h3>Usage example:</h3>
* <pre><code>
* {@code @TextMessageHandler}({"rock", "paper", "scissors"})
* private static void cheaterRockPaperScissors(Message message) {
* bot.execute(new SendMessage(message.chatId(), switch(message.text()) {
* case "rock" -> "paper";
* case "paper" -> "scissors";
* default -> "rock";
* }));
*
* {@code @TextMessageHandler}("/ping")
* private static void ping(Message message) {
* bot.execute(new SendMessage(message.chatId(), String.valueOf(bot.getPing())));
* }
* </code></pre>
* <h5>Last documentation update: 2025-04-05</h5>
* @see Update
* @see Message
* @since 1.0.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface TextMessageHandler {
/**
* Values to match against {@link Message#text()}.
* If set to "*", this method will handle all {@link Message} updates,
* overriding any other {@code @TextMessageHandler} annotations.
*
* @return array of matching strings
*/
@NotNull String[] value() default "*";
}

View File

@@ -1,19 +0,0 @@
package hdvtdev.telegram.annotations.util;
import hdvtdev.telegram.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 {
}

View File

@@ -1,18 +0,0 @@
package hdvtdev.telegram.annotations.util;
import hdvtdev.telegram.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 is not tested, usually used if the method was created recently.
* @since 1.0.0
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.SOURCE)
public @interface NotTested {
}

View File

@@ -1,4 +1,4 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core;
import java.lang.reflect.Method;

View File

@@ -1,52 +0,0 @@
package hdvtdev.telegram.core.objects;
import hdvtdev.telegram.annotations.handlers.TextMessageHandler;
import hdvtdev.telegram.longpolling
import hdvtdev.telegram.core.TelegramBot;
import hdvtdev.telegram.core.UpdateConsumer;
import hdvtdev.telegram.methods.*;
import hdvtdev.telegram.objects.*;
import hdvtdev.telegram.util.ClassFinder;
import java.util.List;
public class Main {
private static String apiKey;
private static long idd = 2027845508;
public static TelegramBot bot;
@TextMessageHandler("пинг")
private static void ping(Message message) {
bot.execute(new SendMessage(message.chatId(), String.valueOf(bot.getPing())));
}
public static void main(String[] args) throws Exception {
bot = new OkHttpTelegramBot.Builder(args[0]).enableHandlers(true).build();
bot.enableDefaultUpdateConsumer();
apiKey = args[2];
}
private static class Upd implements UpdateConsumer, ClassFinder.ErrorHandler {
@Override
public void onError(Throwable throwable) {
throwable.printStackTrace();
}
@Override
public void getUpdates(List<Update> updates) {
updates.forEach(System.out::println);
}
}
}

View File

@@ -1,10 +1,10 @@
package hdvtdev.telegram.core.bot;
package hdvtdev.telegram.core;
import hdvtdev.telegram.exceptions.TelegramApiException;
import hdvtdev.telegram.exceptions.TelegramApiNetworkException;
import hdvtdev.telegram.exceptions.TelegramMethodParsingException;
import hdvtdev.telegram.methods.TelegramApiMethod;
import hdvtdev.telegram.objects.TelegramFile;
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;

View File

@@ -1,4 +1,4 @@
package hdvtdev.telegram.core.bot;
package hdvtdev.telegram.core;
import hdvtdev.telegram.core.objects.Update;

View File

@@ -1,4 +1,4 @@
package hdvtdev.telegram.core.bot;
package hdvtdev.telegram.core;
public interface UserState {
}

View File

@@ -1,6 +1,5 @@
package hdvtdev.telegram.exceptions;
package hdvtdev.telegram.core.exceptions;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

View File

@@ -1,4 +1,4 @@
package hdvtdev.telegram.exceptions;
package hdvtdev.telegram.core.exceptions;
import java.io.IOException;

View File

@@ -1,4 +1,4 @@
package hdvtdev.telegram.exceptions;
package hdvtdev.telegram.core.exceptions;
public class TelegramMethodParsingException extends RuntimeException {
public TelegramMethodParsingException(String message) {

View File

@@ -1,22 +1,19 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.methods;
import hdvtdev.telegram.annotations.util.NotTested;
import hdvtdev.telegram.objects.Game;
import hdvtdev.telegram.core.objects.Game;
import okhttp3.FormBody;
import okhttp3.RequestBody;
/**
* 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 bot via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.
* 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 class AnswerCallbackQuery implements TelegramApiMethod<Boolean> {
//@NotTested
public final class AnswerCallbackQuery implements TelegramApiMethod<Boolean> {
/**
* Unique identifier for the query to be answered
@@ -33,7 +30,7 @@ public class AnswerCallbackQuery implements TelegramApiMethod<Boolean> {
/**
* 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 bot with a parameter.
* 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;
@@ -56,13 +53,14 @@ public class AnswerCallbackQuery implements TelegramApiMethod<Boolean> {
}
@Override
public RequestBody getBody() {
FormBody.Builder builder = new FormBody.Builder().add("callback_query_id", this.callbackQueryId);
if (text != null) builder.add("text", this.text);
if (showAlert != null) builder.add("show_alert", String.valueOf(this.showAlert));
if (url != null) builder.add("url", this.url);
if (cacheTime != null) builder.add("cache_time", String.valueOf(this.cacheTime));
return builder.build();
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

View File

@@ -1,18 +1,13 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.methods;
import hdvtdev.telegram.annotations.util.NotTested;
import hdvtdev.telegram.objects.ChatAdministratorRights;
import hdvtdev.telegram.objects.Chat;
import hdvtdev.telegram.objects.User;
import hdvtdev.telegram.core.objects.chat.Chat;
import hdvtdev.telegram.core.objects.chat.ChatAdministratorRights;
import hdvtdev.telegram.core.objects.User;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import org.jetbrains.annotations.NotNull;
/**
* Use this method to approve a chat join request.
* The bot must be an <u>administrator</u> in the chat for this to work and must have the {@link ChatAdministratorRights#canInviteUsers()} administrator right.
* 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
@@ -21,8 +16,8 @@ import org.jetbrains.annotations.NotNull;
* @see Chat#id()
* @since 0.1.0
*/
@NotTested
public record ApproveChatJoinRequest(@NotNull String chatId, long userId) implements TelegramApiMethod<Boolean> {
//TODO NotTested
public record ApproveChatJoinRequest(String chatId, long userId) implements TelegramApiMethod<Boolean> {
/**
* @param chatId Unique identifier for the target chat
@@ -35,8 +30,11 @@ public record ApproveChatJoinRequest(@NotNull String chatId, long userId) implem
}
@Override
public RequestBody getBody() {
return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build();
public TelegramApiMethodBody getBody() {
TelegramApiMethodBody body = new TelegramApiMethodBody();
body.add("chat_id", chatId);
body.add("user_id", String.valueOf(userId));
return body;
}
@Override

View File

@@ -1,20 +1,19 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.methods;
import hdvtdev.telegram.core.objects.chat.ChatAdministratorRights;
import hdvtdev.telegram.annotations.util.NotTested;
import hdvtdev.telegram.objects.ChatAdministratorRights;
import okhttp3.FormBody;
import okhttp3.RequestBody;
/**
* 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 bot must be an administrator in the chat for this to work and must have
* 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
*/
@NotTested
//TODO NotTested
public final class BanChatMember implements TelegramApiMethod<Boolean> {
/**
@@ -33,8 +32,8 @@ public final class BanChatMember implements TelegramApiMethod<Boolean> {
*/
private Long untilDate;
/**
* Pass true to delete all messages from the chat for the user that is being removed.
* If false, the user will be able to see messages in the group that were sent before the user was removed.
* 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;
@@ -65,11 +64,13 @@ public final class BanChatMember implements TelegramApiMethod<Boolean> {
}
@Override
public RequestBody getBody() {
FormBody.Builder builder = new FormBody.Builder().add("chat_id", this.chatId).add("user_id", String.valueOf(userId));
if (untilDate != null) builder.add("until_date", String.valueOf(untilDate));
if (revokeMessages != null) builder.add("revoke_messages", String.valueOf(revokeMessages));
return builder.build();
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

View File

@@ -1,29 +1,25 @@
package hdvtdev.telegram.core.objects;
import hdvtdev.telegram.annotations.util.NotTested;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import org.jetbrains.annotations.NotNull;
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 messages on behalf of
* their channels. The bot must be an administrator in the supergroup or channel for this to
* 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
*/
@NotTested
public record BanChatSenderChat(@NotNull String chatId, long userId) implements TelegramApiMethod<Boolean> {
//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 RequestBody getBody() {
return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build();
public TelegramApiMethodBody getBody() {
TelegramApiMethodBody body = new TelegramApiMethodBody();
body.add("chat_id", chatId);
body.add("user_id", String.valueOf(userId));
return body;
}
@Override

View File

@@ -1,19 +1,16 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.methods;
import hdvtdev.telegram.annotations.util.NotTested;
import hdvtdev.telegram.objects.ChatAdministratorRights;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import hdvtdev.telegram.core.objects.chat.ChatAdministratorRights;
/**
* Use this method to close an open topic in a forum supergroup chat.
* The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights,
* 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()
*/
@NotTested
//TODO NotTested
public record CloseForumTopic(String chatId, long messageThreadId) implements TelegramApiMethod<Boolean> {
public CloseForumTopic(long chatId, long messageThreadId) {
@@ -21,8 +18,11 @@ public record CloseForumTopic(String chatId, long messageThreadId) implements Te
}
@Override
public RequestBody getBody() {
return new FormBody.Builder().add("chat_id", chatId).add("message_thread_id", String.valueOf(messageThreadId)).build();
public TelegramApiMethodBody getBody() {
TelegramApiMethodBody body = new TelegramApiMethodBody();
body.add("chat_id", chatId);
body.add("message_thread_id", String.valueOf(messageThreadId));
return body;
}
@Override

View File

@@ -1,19 +1,15 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.methods;
import hdvtdev.telegram.annotations.util.NotTested;
import hdvtdev.telegram.objects.ChatAdministratorRights;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import hdvtdev.telegram.core.objects.chat.ChatAdministratorRights;
/**
* Use this method to close an open 'General' topic in a forum supergroup chat.
* The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights.
* 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)
*/
@NotTested
// TODO NotTested
public record CloseGeneralForumTopic(String chatId) implements TelegramApiMethod<Boolean> {
public CloseGeneralForumTopic(long chatId) {
@@ -21,8 +17,10 @@ public record CloseGeneralForumTopic(String chatId) implements TelegramApiMethod
}
@Override
public RequestBody getBody() {
return new FormBody.Builder().add("chat_id", chatId).build();
public TelegramApiMethodBody getBody() {
TelegramApiMethodBody body = new TelegramApiMethodBody();
body.add("chat_id", chatId);
return body;
}
@Override

View File

@@ -1,31 +1,29 @@
package hdvtdev.telegram.core.objects;
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.annotations.util.Jsonable;
import hdvtdev.telegram.annotations.util.NotTested;
import hdvtdev.telegram.objects.MessageEntity;
import hdvtdev.telegram.objects.Poll;
import hdvtdev.telegram.objects.ReplyMarkup;
import hdvtdev.telegram.objects.ReplyParameters;
import hdvtdev.telegram.util.ParseMode;
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 okhttp3.RequestBody;
import java.util.List;
/**
* Use this method to copy messages of any kind.
* Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages 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 bot.
* 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
*/
@NotTested
//TODO NotTested
@Jsonable
@JsonInclude(JsonInclude.Include.NON_NULL)
public final class CopyMessage implements TelegramApiMethod<Long> {
@@ -140,7 +138,7 @@ public final class CopyMessage implements TelegramApiMethod<Long> {
@JsonIgnore
@Override
public RequestBody getBody() {
public TelegramApiMethodBody getBody() {
return null;
}

View File

@@ -1,25 +1,23 @@
package hdvtdev.telegram.core.objects;
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.annotations.util.Jsonable;
import hdvtdev.telegram.objects.Poll;
import okhttp3.RequestBody;
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 messages of any kind.
* If some of the specified messages can't be found or copied, they are skipped.
* Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages 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 bot.
* The method is analogous to the method {@link ForwardMessages}, but the copied messages don't have a link to the original message.
* Album grouping is kept for copied messages.
* On success, an array of MessageId as {@link Long}{@code []} of the sent messages is returned.
* 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
*/
@@ -44,8 +42,8 @@ public final class CopyMessages implements TelegramApiMethod<Long[]> {
/**
* @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 messages were sent
* @param messageIds List of 1-100 identifiers of messages in the chat to copy.
* @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;
@@ -57,8 +55,8 @@ public final class CopyMessages implements TelegramApiMethod<Long[]> {
/**
* @param chatId Unique identifier for the target chat
* @param fromChatId Channel username in the format @channelusername for the chat where the original messages were sent
* @param messageIds List of 1-100 identifiers of messages in the chat to copy.
* @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);
@@ -66,17 +64,17 @@ public final class CopyMessages implements TelegramApiMethod<Long[]> {
/**
* @param chatId Unique identifier for the target chat
* @param fromChatId Unique identifier for the chat where the original messages were sent
* @param messageIds List of 1-100 identifiers of messages in the chat to copy.
* @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 messages were sent
* @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 messages in the chat to copy.
* @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);
@@ -110,7 +108,7 @@ public final class CopyMessages implements TelegramApiMethod<Long[]> {
@JsonIgnore
@Override
public RequestBody getBody() {
public TelegramApiMethodBody getBody() {
return null;
}

View File

@@ -1,14 +1,11 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.methods;
import hdvtdev.telegram.objects.ChatAdministratorRights;
import hdvtdev.telegram.objects.ChatInviteLink;
import okhttp3.FormBody;
import okhttp3.RequestBody;
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 bot must be an administrator in the chat for this to work and must have the appropriate administrator rights.
* 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()
*/
@@ -54,12 +51,14 @@ public final class CreateChatInviteLink implements TelegramApiMethod<ChatInviteL
@Override
public RequestBody getBody() {
FormBody.Builder builder = new FormBody.Builder().add("chat_id", chatId);
if (expireDate != null) builder.add("expire_date", String.valueOf(expireDate));
if (memberLimit != null) builder.add("member_limit", String.valueOf(memberLimit));
if (createsJoinRequest != null) builder.add("creates_join_request", String.valueOf(createsJoinRequest));
return builder.build();
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

View File

@@ -1,17 +1,16 @@
package hdvtdev.telegram.core.objects;
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.annotations.util.Jsonable;
import hdvtdev.telegram.objects.Message;
import hdvtdev.telegram.core.annotaions.Jsonable;
import hdvtdev.telegram.core.objects.message.Message;
import okhttp3.RequestBody;
/**
* Use this method to forward messages of any kind.
* Service messages and messages with protected content can't be forwarded.
* 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
@@ -75,7 +74,7 @@ public final class ForwardMessage implements TelegramApiMethod<Message> {
@JsonIgnore
@Override
public RequestBody getBody() {
public TelegramApiMethodBody getBody() {
return null;
}

View File

@@ -1,26 +1,23 @@
package hdvtdev.telegram.core.objects;
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.annotations.util.Jsonable;
import hdvtdev.telegram.annotations.util.NotTested;
import hdvtdev.telegram.objects.Message;
import okhttp3.RequestBody;
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 messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped.
* Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages.
* On success, an array of MessageId as {@link Long} of the sent messages is returned.
* 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
@NotTested
@JsonInclude(JsonInclude.Include.NON_NULL)
public final class ForwardMessages implements TelegramApiMethod<Long[]> {
@@ -80,7 +77,7 @@ public final class ForwardMessages implements TelegramApiMethod<Long[]> {
@JsonIgnore
@Override
public RequestBody getBody() {
public TelegramApiMethodBody getBody() {
return null;
}

View File

@@ -1,27 +1,23 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.methods;
import hdvtdev.telegram.annotations.util.NotTested;
import hdvtdev.telegram.objects.ChatMember;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import org.jetbrains.annotations.NotNull;
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
*/
@NotTested
public record GetChatAdministrators(@NotNull String chatId) implements TelegramApiMethod<ChatMember[]> {
//TODO NotTested
public record GetChatAdministrators(String chatId) implements TelegramApiMethod<ChatMember[]> {
public GetChatAdministrators(long chatId) {
this(String.valueOf(chatId));
}
@Override
public RequestBody getBody() {
return new FormBody.Builder().add("chat_id", chatId).build();
public TelegramApiMethodBody getBody() {
TelegramApiMethodBody body = new TelegramApiMethodBody();
body.add("chat_id", chatId);
return body;
}
@Override

View File

@@ -1,13 +1,8 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.methods;
import hdvtdev.telegram.objects.ChatMember;
import hdvtdev.telegram.core.objects.chat.ChatMember;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import org.jetbrains.annotations.NotNull;
public record GetChatMember(@NotNull String chatId, long userId) implements TelegramApiMethod<ChatMember> {
public record GetChatMember(String chatId, long userId) implements TelegramApiMethod<ChatMember> {
public GetChatMember(long chatId, long userId) {
this(String.valueOf(chatId), userId);
@@ -22,8 +17,11 @@ public record GetChatMember(@NotNull String chatId, long userId) implements Tele
}
@Override
public RequestBody getBody() {
return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build();
public TelegramApiMethodBody getBody() {
TelegramApiMethodBody body = new TelegramApiMethodBody();
body.add("chat_id", chatId);
body.add("user_id", String.valueOf(userId));
return body;
}
@Override

View File

@@ -1,14 +1,14 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.methods;
import hdvtdev.telegram.objects.TelegramFile;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import hdvtdev.telegram.core.objects.media.TelegramFile;
public record GetFile(String fileId) implements TelegramApiMethod<TelegramFile> {
@Override
public RequestBody getBody() {
return new FormBody.Builder().add("file_id", fileId).build();
public TelegramApiMethodBody getBody() {
TelegramApiMethodBody body = new TelegramApiMethodBody();
body.add("file_id", fileId);
return body;
}
@Override

View File

@@ -1,12 +1,11 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.methods;
import hdvtdev.telegram.objects.User;
import okhttp3.RequestBody;
import hdvtdev.telegram.core.objects.User;
public final class GetMe implements TelegramApiMethod<User.Bot> {
@Override
public RequestBody getBody() {
public TelegramApiMethodBody getBody() {
return null;
}

View File

@@ -1,18 +1,16 @@
package hdvtdev.telegram.core.objects;
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.annotations.util.Jsonable;
import hdvtdev.telegram.objects.bot.BotCommand;
import hdvtdev.telegram.objects.bot.BotCommandScope;
import hdvtdev.telegram.objects.bot.BotCommandScopeDefault;
import okhttp3.RequestBody;
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 bot's commands for the given scope and user language.
* 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
@@ -40,7 +38,7 @@ public record GetMyCommands(
@JsonIgnore
@Override
public RequestBody getBody() {
public TelegramApiMethodBody getBody() {
return null;
}

View File

@@ -1,9 +1,4 @@
package hdvtdev.telegram.core.objects;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import org.jetbrains.annotations.NotNull;
package hdvtdev.telegram.core.methods;
public record GetMyDescription(String languageCode) implements TelegramApiMethod<GetMyDescription.BotDescription> {
@@ -12,8 +7,14 @@ public record GetMyDescription(String languageCode) implements TelegramApiMethod
}
@Override
public RequestBody getBody() {
return languageCode == null ? null : new FormBody.Builder().add("language_code", languageCode).build();
public TelegramApiMethodBody getBody() {
if (languageCode == null) {
return null;
} else {
TelegramApiMethodBody body = new TelegramApiMethodBody();
body.add("language_code", languageCode);
return body;
}
}
@Override
@@ -27,7 +28,7 @@ public record GetMyDescription(String languageCode) implements TelegramApiMethod
}
public record BotDescription(String description) {
@NotNull
@Override
public String toString() {
return description;

View File

@@ -1,8 +1,4 @@
package hdvtdev.telegram.core.objects;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import org.jetbrains.annotations.NotNull;
package hdvtdev.telegram.core.methods;
public record GetMyName(String languageCode) implements TelegramApiMethod<GetMyName.BotName> {
@@ -11,8 +7,14 @@ public record GetMyName(String languageCode) implements TelegramApiMethod<GetMyN
}
@Override
public RequestBody getBody() {
return this.languageCode == null ? null : new FormBody.Builder().add("language_code", this.languageCode).build();
public TelegramApiMethodBody getBody() {
if (languageCode == null) {
return null;
} else {
TelegramApiMethodBody body = new TelegramApiMethodBody();
body.add("language_code", languageCode);
return body;
}
}
@Override
@@ -27,7 +29,6 @@ public record GetMyName(String languageCode) implements TelegramApiMethod<GetMyN
public record BotName(String name) {
@NotNull
@Override
public String toString() {
return this.name;

View File

@@ -1,8 +1,6 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.methods;
import hdvtdev.telegram.objects.Update;
import okhttp3.RequestBody;
import hdvtdev.telegram.core.objects.Update;
import java.util.ArrayList;
@@ -17,7 +15,7 @@ public record GetUpdates(
}
@Override
public RequestBody getBody() {
public TelegramApiMethodBody getBody() {
return null;
}

View File

@@ -1,28 +1,26 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.methods;
import hdvtdev.telegram.objects.ChatInviteLink;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import org.jetbrains.annotations.NotNull;
import hdvtdev.telegram.core.objects.chat.ChatInviteLink;
/**
* Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated.
* The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights.
* 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(@NotNull String chatId, @NotNull String link) implements TelegramApiMethod<ChatInviteLink> {
public record RevokeChatInviteLink(String chatId, String link) implements TelegramApiMethod<ChatInviteLink> {
public RevokeChatInviteLink(long chatId, @NotNull String link) {
public RevokeChatInviteLink(long chatId, String link) {
this(String.valueOf(chatId), link);
}
@Override
public RequestBody getBody() {
return new FormBody.Builder().add("chat_id", chatId).add("link", link).build();
public TelegramApiMethodBody getBody() {
TelegramApiMethodBody body = new TelegramApiMethodBody(2);
body.add("chat_id", chatId);
body.add("link", link);
return body;
}
@Override

View File

@@ -1,10 +1,4 @@
package hdvtdev.telegram.core.objects;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
package hdvtdev.telegram.core.methods;
public final class SendChatAction implements TelegramApiMethod<Boolean> {
@@ -13,7 +7,7 @@ public final class SendChatAction implements TelegramApiMethod<Boolean> {
private Long messageThreadId;
private final ChatAction chatAction;
public SendChatAction(@Nullable String businessConnectionId, @NotNull String chatId, @Nullable Long messageThreadId, @NotNull ChatAction chatAction) {
public SendChatAction(String businessConnectionId, String chatId, Long messageThreadId, ChatAction chatAction) {
this.businessConnectionId = businessConnectionId;
this.chatId = chatId;
this.messageThreadId = messageThreadId;
@@ -41,14 +35,13 @@ public final class SendChatAction implements TelegramApiMethod<Boolean> {
}
@Override
public RequestBody getBody() {
FormBody.Builder builder = new FormBody.Builder().add("chat_id", chatId).add("action", chatAction.equals(ChatAction.UPLOAD_FILE) ? ChatAction.UPLOAD_DOCUMENT.name() : chatAction.name());
if (businessConnectionId != null) builder.add("business_connection_id", businessConnectionId);
if (messageThreadId != null) builder.add("message_thread_id", String.valueOf(messageThreadId));
return builder.build();
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

View File

@@ -1,15 +1,13 @@
package hdvtdev.telegram.core.objects;
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.annotations.util.Jsonable;
import hdvtdev.telegram.objects.Message;
import hdvtdev.telegram.objects.ReplyMarkup;
import hdvtdev.telegram.objects.ReplyParameters;
import okhttp3.RequestBody;
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)
@@ -92,7 +90,7 @@ public final class SendDice implements TelegramApiMethod<Message> {
@JsonIgnore
@Override
public RequestBody getBody() {
public TelegramApiMethodBody getBody() {
return null;
}

View File

@@ -1,14 +1,17 @@
package hdvtdev.telegram.core.objects;
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.annotations.util.Jsonable;
import hdvtdev.telegram.objects.*;
import hdvtdev.telegram.util.ParseMode;
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;
import okhttp3.RequestBody;
@Jsonable
@JsonInclude(JsonInclude.Include.NON_NULL)
@@ -118,7 +121,7 @@ public final class SendMessage implements TelegramApiMethod<Message> {
@JsonIgnore
@Override
public RequestBody getBody() {
public TelegramApiMethodBody getBody() {
return null;
}

View File

@@ -1,13 +1,11 @@
package hdvtdev.telegram.core.objects;
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.annotations.util.Jsonable;
import hdvtdev.telegram.objects.ReactionType;
import okhttp3.RequestBody;
import hdvtdev.telegram.core.annotaions.Jsonable;
import hdvtdev.telegram.core.objects.reaction.ReactionType;
import java.util.List;
@@ -51,7 +49,7 @@ public class SetMessageReaction implements TelegramApiMethod<Boolean> {
@JsonIgnore
@Override
public RequestBody getBody() {
public TelegramApiMethodBody getBody() {
return null;
}

View File

@@ -1,13 +1,12 @@
package hdvtdev.telegram.core.objects;
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.annotations.util.Jsonable;
import hdvtdev.telegram.objects.bot.BotCommand;
import hdvtdev.telegram.objects.bot.BotCommandScope;
import okhttp3.RequestBody;
import hdvtdev.telegram.core.annotaions.Jsonable;
import hdvtdev.telegram.core.objects.command.BotCommand;
import hdvtdev.telegram.core.objects.command.BotCommandScope;
import java.util.List;
@@ -53,7 +52,7 @@ public final class SetMyCommands implements TelegramApiMethod<Boolean> {
@JsonIgnore
@Override
public RequestBody getBody() {
public TelegramApiMethodBody getBody() {
return null;
}

View File

@@ -1,12 +1,9 @@
package hdvtdev.telegram.core.objects;
import okhttp3.FormBody;
import okhttp3.RequestBody;
package hdvtdev.telegram.core.methods;
/**
* Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.
* 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 bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.
* @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> {
@@ -20,13 +17,15 @@ public record SetMyDescription(String description, String languageCode) implemen
}
@Override
public RequestBody getBody() {
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;
}
FormBody.Builder builder = new FormBody.Builder().add("description", description);
if (languageCode != null) builder.add("language_code", languageCode);
return builder.build();
}
@Override

View File

@@ -1,7 +1,4 @@
package hdvtdev.telegram.core.objects;
import okhttp3.FormBody;
import okhttp3.RequestBody;
package hdvtdev.telegram.core.methods;
public record SetMyName(String name, String languageCode) implements TelegramApiMethod<Boolean> {
@@ -10,10 +7,11 @@ public record SetMyName(String name, String languageCode) implements TelegramApi
}
@Override
public RequestBody getBody() {
FormBody.Builder builder = new FormBody.Builder().add("name", this.name);
if (languageCode != null) builder.add("language_code", this.languageCode);
return builder.build();
public TelegramApiMethodBody getBody() {
TelegramApiMethodBody body = new TelegramApiMethodBody(2);
body.add("name", this.name);
body.add("language_code", this.languageCode);
return body;
}
@Override

View File

@@ -1,10 +1,8 @@
package hdvtdev.telegram.core.objects;
import okhttp3.RequestBody;
package hdvtdev.telegram.core.methods;
public interface TelegramApiMethod<T> {
RequestBody getBody();
TelegramApiMethodBody getBody();
String getMethodName();

View File

@@ -1,4 +1,4 @@
package hdvtdev.telegram.core.bot;
package hdvtdev.telegram.core.methods;
import java.util.ArrayList;
import java.util.function.Consumer;

View File

@@ -1,4 +1,4 @@
package hdvtdev.telegram.core;
package hdvtdev.telegram.core.methods.util;
public enum ParseMode {
MARKDOWN,

View File

@@ -1,4 +1,4 @@
package hdvtdev.telegram.core;
package hdvtdev.telegram.core.methods.util;
import java.io.BufferedWriter;
import java.io.FileWriter;

View File

@@ -1,113 +0,0 @@
package hdvtdev.telegram.core.objects;
import hdvtdev.telegram.annotations.util.NotTested;
import hdvtdev.telegram.objects.Game;
import okhttp3.FormBody;
import okhttp3.RequestBody;
/**
* 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 bot via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.
* @apiNote On success, {@code Boolean == true} is returned.
* @since 1.0.0
*/
@NotTested
public 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 bot 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 RequestBody getBody() {
FormBody.Builder builder = new FormBody.Builder().add("callback_query_id", this.callbackQueryId);
if (text != null) builder.add("text", this.text);
if (showAlert != null) builder.add("show_alert", String.valueOf(this.showAlert));
if (url != null) builder.add("url", this.url);
if (cacheTime != null) builder.add("cache_time", String.valueOf(this.cacheTime));
return builder.build();
}
@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);
}
}
}

View File

@@ -1,51 +0,0 @@
package hdvtdev.telegram.core.objects;
import hdvtdev.telegram.annotations.util.NotTested;
import hdvtdev.telegram.objects.ChatAdministratorRights;
import hdvtdev.telegram.objects.Chat;
import hdvtdev.telegram.objects.User;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import org.jetbrains.annotations.NotNull;
/**
* Use this method to approve a chat join request.
* The bot 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
*/
@NotTested
public record ApproveChatJoinRequest(@NotNull 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 RequestBody getBody() {
return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build();
}
@Override
public String getMethodName() {
return "approveChatJoinRequest";
}
@Override
public Class<Boolean> getResponseClass() {
return Boolean.class;
}
}

View File

@@ -1,110 +0,0 @@
package hdvtdev.telegram.core.objects;
import hdvtdev.telegram.annotations.util.NotTested;
import hdvtdev.telegram.objects.ChatAdministratorRights;
import okhttp3.FormBody;
import okhttp3.RequestBody;
/**
* 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 bot 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
*/
@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 messages from the chat for the user that is being removed.
* If false, the user will be able to see messages 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 RequestBody getBody() {
FormBody.Builder builder = new FormBody.Builder().add("chat_id", this.chatId).add("user_id", String.valueOf(userId));
if (untilDate != null) builder.add("until_date", String.valueOf(untilDate));
if (revokeMessages != null) builder.add("revoke_messages", String.valueOf(revokeMessages));
return builder.build();
}
@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);
}
}
}

View File

@@ -1,38 +0,0 @@
package hdvtdev.telegram.core.objects;
import hdvtdev.telegram.annotations.util.NotTested;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import org.jetbrains.annotations.NotNull;
/**
* 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 messages on behalf of
* their channels. The bot 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
*/
@NotTested
public record BanChatSenderChat(@NotNull String chatId, long userId) implements TelegramApiMethod<Boolean> {
public BanChatSenderChat(long chatId, long userId) {
this(String.valueOf(chatId), userId);
}
@Override
public RequestBody getBody() {
return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build();
}
@Override
public String getMethodName() {
return "banChatSenderChat";
}
@Override
public Class<Boolean> getResponseClass() {
return Boolean.class;
}
}

View File

@@ -1,37 +0,0 @@
package hdvtdev.telegram.core.objects;
import hdvtdev.telegram.annotations.util.NotTested;
import hdvtdev.telegram.objects.ChatAdministratorRights;
import okhttp3.FormBody;
import okhttp3.RequestBody;
/**
* Use this method to close an open topic in a forum supergroup chat.
* The bot 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()
*/
@NotTested
public record CloseForumTopic(String chatId, long messageThreadId) implements TelegramApiMethod<Boolean> {
public CloseForumTopic(long chatId, long messageThreadId) {
this(String.valueOf(chatId), messageThreadId);
}
@Override
public RequestBody getBody() {
return new FormBody.Builder().add("chat_id", chatId).add("message_thread_id", String.valueOf(messageThreadId)).build();
}
@Override
public String getMethodName() {
return "closeForumTopic";
}
@Override
public Class<Boolean> getResponseClass() {
return Boolean.class;
}
}

View File

@@ -1,37 +0,0 @@
package hdvtdev.telegram.core.objects;
import hdvtdev.telegram.annotations.util.NotTested;
import hdvtdev.telegram.objects.ChatAdministratorRights;
import okhttp3.FormBody;
import okhttp3.RequestBody;
/**
* Use this method to close an open 'General' topic in a forum supergroup chat.
* The bot 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)
*/
@NotTested
public record CloseGeneralForumTopic(String chatId) implements TelegramApiMethod<Boolean> {
public CloseGeneralForumTopic(long chatId) {
this(String.valueOf(chatId));
}
@Override
public RequestBody getBody() {
return new FormBody.Builder().add("chat_id", chatId).build();
}
@Override
public String getMethodName() {
return "closeGeneralForumTopic";
}
@Override
public Class<Boolean> getResponseClass() {
return Boolean.class;
}
}

View File

@@ -1,244 +0,0 @@
package hdvtdev.telegram.core.objects;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import hdvtdev.telegram.annotations.util.Jsonable;
import hdvtdev.telegram.annotations.util.NotTested;
import hdvtdev.telegram.objects.MessageEntity;
import hdvtdev.telegram.objects.Poll;
import hdvtdev.telegram.objects.ReplyMarkup;
import hdvtdev.telegram.objects.ReplyParameters;
import hdvtdev.telegram.util.ParseMode;
import okhttp3.RequestBody;
import java.util.List;
/**
* Use this method to copy messages of any kind.
* Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages 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 bot.
* 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
*/
@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 RequestBody 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);
}
}
}

View File

@@ -1,181 +0,0 @@
package hdvtdev.telegram.core.objects;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import hdvtdev.telegram.annotations.util.Jsonable;
import hdvtdev.telegram.objects.Poll;
import okhttp3.RequestBody;
import java.util.ArrayList;
import java.util.List;
/**
* Use this method to copy messages of any kind.
* If some of the specified messages can't be found or copied, they are skipped.
* Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages 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 bot.
* The method is analogous to the method {@link ForwardMessages}, but the copied messages don't have a link to the original message.
* Album grouping is kept for copied messages.
* On success, an array of MessageId as {@link Long}{@code []} of the sent messages 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 messages were sent
* @param messageIds List of 1-100 identifiers of messages 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 messages were sent
* @param messageIds List of 1-100 identifiers of messages 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 messages were sent
* @param messageIds List of 1-100 identifiers of messages 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 messages were sent
* @param fromChatId Unique identifier for the target chat
* @param messageIds List of 1-100 identifiers of messages 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 RequestBody 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);
}
}
}

View File

@@ -1,114 +0,0 @@
package hdvtdev.telegram.core.objects;
import hdvtdev.telegram.objects.ChatAdministratorRights;
import hdvtdev.telegram.objects.ChatInviteLink;
import okhttp3.FormBody;
import okhttp3.RequestBody;
/**
* Use this method to create an additional invite link for a chat.
* The bot 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 RequestBody getBody() {
FormBody.Builder builder = new FormBody.Builder().add("chat_id", chatId);
if (expireDate != null) builder.add("expire_date", String.valueOf(expireDate));
if (memberLimit != null) builder.add("member_limit", String.valueOf(memberLimit));
if (createsJoinRequest != null) builder.add("creates_join_request", String.valueOf(createsJoinRequest));
return builder.build();
}
@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);
}
}
}

View File

@@ -1,133 +0,0 @@
package hdvtdev.telegram.core.objects;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import hdvtdev.telegram.annotations.util.Jsonable;
import hdvtdev.telegram.objects.Message;
import okhttp3.RequestBody;
/**
* Use this method to forward messages of any kind.
* Service messages and messages 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 RequestBody 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);
}
}
}

View File

@@ -1,147 +0,0 @@
package hdvtdev.telegram.core.objects;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import hdvtdev.telegram.annotations.util.Jsonable;
import hdvtdev.telegram.annotations.util.NotTested;
import hdvtdev.telegram.objects.Message;
import okhttp3.RequestBody;
import java.util.ArrayList;
import java.util.List;
/**
* Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped.
* Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages.
* On success, an array of MessageId as {@link Long} of the sent messages is returned.
* @see Message#hasProtectedContent()
*/
@Jsonable
@NotTested
@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 RequestBody 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);
}
}
}

View File

@@ -3,6 +3,9 @@ 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)

View File

@@ -1,36 +0,0 @@
package hdvtdev.telegram.core.objects;
import hdvtdev.telegram.annotations.util.NotTested;
import hdvtdev.telegram.objects.ChatMember;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import org.jetbrains.annotations.NotNull;
/**
* 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
*/
@NotTested
public record GetChatAdministrators(@NotNull String chatId) implements TelegramApiMethod<ChatMember[]> {
public GetChatAdministrators(long chatId) {
this(String.valueOf(chatId));
}
@Override
public RequestBody getBody() {
return new FormBody.Builder().add("chat_id", chatId).build();
}
@Override
public String getMethodName() {
return "getChatAdministrators";
}
@Override
public Class<ChatMember[]> getResponseClass() {
return ChatMember[].class;
}
}

View File

@@ -1,38 +0,0 @@
package hdvtdev.telegram.core.objects;
import hdvtdev.telegram.objects.ChatMember;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import org.jetbrains.annotations.NotNull;
public record GetChatMember(@NotNull 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 RequestBody getBody() {
return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build();
}
@Override
public String getMethodName() {
return "getChatMember";
}
@Override
public Class<ChatMember> getResponseClass() {
return ChatMember.class;
}
}

View File

@@ -1,23 +0,0 @@
package hdvtdev.telegram.core.objects;
import hdvtdev.telegram.objects.TelegramFile;
import okhttp3.FormBody;
import okhttp3.RequestBody;
public record GetFile(String fileId) implements TelegramApiMethod<TelegramFile> {
@Override
public RequestBody getBody() {
return new FormBody.Builder().add("file_id", fileId).build();
}
@Override
public String getMethodName() {
return "getFile";
}
@Override
public Class<TelegramFile> getResponseClass() {
return TelegramFile.class;
}
}

View File

@@ -1,22 +0,0 @@
package hdvtdev.telegram.core.objects;
import hdvtdev.telegram.objects.User;
import okhttp3.RequestBody;
public final class GetMe implements TelegramApiMethod<User.Bot> {
@Override
public RequestBody getBody() {
return null;
}
@Override
public String getMethodName() {
return "getMe";
}
@Override
public Class<User.Bot> getResponseClass() {
return User.Bot.class;
}
}

View File

@@ -1,58 +0,0 @@
package hdvtdev.telegram.core.objects;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import hdvtdev.telegram.annotations.util.Jsonable;
import hdvtdev.telegram.objects.bot.BotCommand;
import hdvtdev.telegram.objects.bot.BotCommandScope;
import hdvtdev.telegram.objects.bot.BotCommandScopeDefault;
import okhttp3.RequestBody;
/**
* Use this method to get the current list of the bot'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 RequestBody getBody() {
return null;
}
@JsonIgnore
@Override
public String getMethodName() {
return "getMyCommands";
}
@JsonIgnore
@Override
public Class<BotCommand[]> getResponseClass() {
return BotCommand[].class;
}
}

View File

@@ -1,42 +0,0 @@
package hdvtdev.telegram.core.objects;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import org.jetbrains.annotations.NotNull;
public record GetMyDescription(String languageCode) implements TelegramApiMethod<GetMyDescription.BotDescription> {
public GetMyDescription() {
this(null);
}
@Override
public RequestBody getBody() {
return languageCode == null ? null : new FormBody.Builder().add("language_code", languageCode).build();
}
@Override
public String getMethodName() {
return "getMyDescription";
}
@Override
public Class<BotDescription> getResponseClass() {
return BotDescription.class;
}
public record BotDescription(String description) {
@NotNull
@Override
public String toString() {
return description;
}
public boolean isEmpty() {
return description.isEmpty();
}
}
}

View File

@@ -1,38 +0,0 @@
package hdvtdev.telegram.core.objects;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import org.jetbrains.annotations.NotNull;
public record GetMyName(String languageCode) implements TelegramApiMethod<GetMyName.BotName> {
public GetMyName() {
this(null);
}
@Override
public RequestBody getBody() {
return this.languageCode == null ? null : new FormBody.Builder().add("language_code", this.languageCode).build();
}
@Override
public String getMethodName() {
return "getMyName";
}
@Override
public Class<BotName> getResponseClass() {
return BotName.class;
}
public record BotName(String name) {
@NotNull
@Override
public String toString() {
return this.name;
}
}
}

View File

@@ -1,42 +0,0 @@
package hdvtdev.telegram.core.objects;
import hdvtdev.telegram.objects.Update;
import okhttp3.RequestBody;
import java.util.ArrayList;
public record GetUpdates(
Long offset,
Integer limit,
Integer timeout
) implements TelegramApiMethod<Update[]> {
public GetUpdates() {
this(null, null, null);
}
@Override
public RequestBody 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;
}
}

View File

@@ -3,6 +3,7 @@ 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)

View File

@@ -1,37 +0,0 @@
package hdvtdev.telegram.core.objects;
import hdvtdev.telegram.objects.ChatInviteLink;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import org.jetbrains.annotations.NotNull;
/**
* Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated.
* The bot 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(@NotNull String chatId, @NotNull String link) implements TelegramApiMethod<ChatInviteLink> {
public RevokeChatInviteLink(long chatId, @NotNull String link) {
this(String.valueOf(chatId), link);
}
@Override
public RequestBody getBody() {
return new FormBody.Builder().add("chat_id", chatId).add("link", link).build();
}
@Override
public String getMethodName() {
return "revokeChatInviteLink";
}
@Override
public Class<ChatInviteLink> getResponseClass() {
return ChatInviteLink.class;
}
}

View File

@@ -1,104 +0,0 @@
package hdvtdev.telegram.core.objects;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public final class SendChatAction implements TelegramApiMethod<Boolean> {
private String businessConnectionId;
private final String chatId;
private Long messageThreadId;
private final ChatAction chatAction;
public SendChatAction(@Nullable String businessConnectionId, @NotNull String chatId, @Nullable Long messageThreadId, @NotNull 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 RequestBody getBody() {
FormBody.Builder builder = new FormBody.Builder().add("chat_id", chatId).add("action", chatAction.equals(ChatAction.UPLOAD_FILE) ? ChatAction.UPLOAD_DOCUMENT.name() : chatAction.name());
if (businessConnectionId != null) builder.add("business_connection_id", businessConnectionId);
if (messageThreadId != null) builder.add("message_thread_id", String.valueOf(messageThreadId));
return builder.build();
}
@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);
}
}
}

View File

@@ -1,133 +0,0 @@
package hdvtdev.telegram.core.objects;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import hdvtdev.telegram.annotations.util.Jsonable;
import hdvtdev.telegram.objects.Message;
import hdvtdev.telegram.objects.ReplyMarkup;
import hdvtdev.telegram.objects.ReplyParameters;
import okhttp3.RequestBody;
@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 RequestBody 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;
}
}
}

View File

@@ -1,226 +0,0 @@
package hdvtdev.telegram.core.objects;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import hdvtdev.telegram.annotations.util.Jsonable;
import hdvtdev.telegram.objects.*;
import hdvtdev.telegram.util.ParseMode;
import okhttp3.RequestBody;
@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 RequestBody 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);
}
}
}

View File

@@ -1,100 +0,0 @@
package hdvtdev.telegram.core.objects;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import hdvtdev.telegram.annotations.util.Jsonable;
import hdvtdev.telegram.objects.ReactionType;
import okhttp3.RequestBody;
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 RequestBody 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);
}
}
}

View File

@@ -1,100 +0,0 @@
package hdvtdev.telegram.core.objects;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import hdvtdev.telegram.annotations.util.Jsonable;
import hdvtdev.telegram.objects.bot.BotCommand;
import hdvtdev.telegram.objects.bot.BotCommandScope;
import okhttp3.RequestBody;
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 RequestBody 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);
}
}
}

View File

@@ -1,41 +0,0 @@
package hdvtdev.telegram.core.objects;
import okhttp3.FormBody;
import okhttp3.RequestBody;
/**
* Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.
* Returns {@code true} on success.
* @param description New bot 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 RequestBody getBody() {
if (description == null) {
return null;
}
FormBody.Builder builder = new FormBody.Builder().add("description", description);
if (languageCode != null) builder.add("language_code", languageCode);
return builder.build();
}
@Override
public String getMethodName() {
return "setMyDescription";
}
@Override
public Class<Boolean> getResponseClass() {
return Boolean.class;
}
}

View File

@@ -1,28 +0,0 @@
package hdvtdev.telegram.core.objects;
import okhttp3.FormBody;
import okhttp3.RequestBody;
public record SetMyName(String name, String languageCode) implements TelegramApiMethod<Boolean> {
public SetMyName(String name) {
this(name, null);
}
@Override
public RequestBody getBody() {
FormBody.Builder builder = new FormBody.Builder().add("name", this.name);
if (languageCode != null) builder.add("language_code", this.languageCode);
return builder.build();
}
@Override
public String getMethodName() {
return "setMyName";
}
@Override
public Class<Boolean> getResponseClass() {
return Boolean.class;
}
}

View File

@@ -3,6 +3,7 @@ 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)

View File

@@ -1,13 +0,0 @@
package hdvtdev.telegram.core.objects;
import okhttp3.RequestBody;
public interface TelegramApiMethod<T> {
RequestBody getBody();
String getMethodName();
Class<T> getResponseClass();
}

View File

@@ -3,6 +3,21 @@ 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;

View File

@@ -1,4 +1,4 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.objects.background;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

View File

@@ -1,4 +1,27 @@
package hdvtdev.telegram.core.objects.background;
public class BackgroundFillDeserializer {
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);
};
}
}

View File

@@ -1,4 +1,4 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.objects.background;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

View File

@@ -1,4 +1,4 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.objects.background;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

View File

@@ -1,4 +1,4 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.objects.background;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

View File

@@ -1,19 +1,8 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.objects.background;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXISTING_PROPERTY,
property = "type"
)
@JsonSubTypes({
@JsonSubTypes.Type(value = BackgroundTypeFill.class, name = "fill"),
@JsonSubTypes.Type(value = BackgroundTypeWallpaper.class, name = "wallpaper"),
@JsonSubTypes.Type(value = BackgroundTypePattern.class, name = "pattern"),
@JsonSubTypes.Type(value = BackgroundTypeChatTheme.class, name = "chat_theme")
})
@JsonDeserialize(using = BackgroundTypeDeserializer.class)
public interface BackgroundType {
String type();
}

View File

@@ -1,4 +1,4 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.objects.background;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

View File

@@ -1,4 +1,28 @@
package hdvtdev.telegram.core.objects.background;
public class BackgroundTypeDeserializer {
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);
};
}
}

View File

@@ -1,4 +1,4 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.objects.background;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

View File

@@ -1,8 +1,9 @@
package hdvtdev.telegram.core.objects;
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)

View File

@@ -1,8 +1,9 @@
package hdvtdev.telegram.core.objects;
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)

View File

@@ -1,8 +1,9 @@
package hdvtdev.telegram.core.objects;
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)

View File

@@ -1,4 +1,4 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.objects.business;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

View File

@@ -1,4 +1,4 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.objects.callback;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

View File

@@ -1,8 +1,9 @@
package hdvtdev.telegram.core.objects;
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)

View File

@@ -1,4 +1,4 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.objects.chat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

View File

@@ -1,4 +1,4 @@
package hdvtdev.telegram.core.objects;
package hdvtdev.telegram.core.objects.chat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

View File

@@ -1,8 +1,9 @@
package hdvtdev.telegram.core.objects;
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)

View File

@@ -1,10 +1,10 @@
package hdvtdev.telegram.core.objects;
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 org.jetbrains.annotations.NotNull;
import hdvtdev.telegram.core.objects.User;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -21,7 +21,6 @@ public record ChatInviteLink(
@JsonProperty("subscription_period") int subscriptionPeriod,
@JsonProperty("subscription_price") int subscriptionPrice
) {
@NotNull
@Override
public String toString() {
return this.inviteLink;

View File

@@ -1,8 +1,9 @@
package hdvtdev.telegram.core.objects;
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)

View File

@@ -1,7 +1,8 @@
package hdvtdev.telegram.core.objects;
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,

View File

@@ -1,8 +1,9 @@
package hdvtdev.telegram.core.objects;
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)

View File

@@ -1,8 +1,9 @@
package hdvtdev.telegram.core.objects;
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)

View File

@@ -1,8 +1,9 @@
package hdvtdev.telegram.core.objects;
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)

Some files were not shown because too many files have changed in this diff Show More