Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Bot API 7.4 #21

Merged
merged 6 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public record CopyMessage(
String fromChatId,

@JsonProperty(value = "message_id", required = true)
long messageId,
int messageId,

@JsonProperty(value = "caption")
@Nullable
Expand All @@ -36,6 +36,9 @@ public record CopyMessage(
@Nullable
MessageEntity[] captionEntities,

@JsonProperty("show_caption_above_media")
boolean showCaptionAboveMedia,

@JsonProperty(value = "disable_notification")
boolean disableNotification,

Expand All @@ -51,7 +54,7 @@ public record CopyMessage(
ReplyKeyboard replyMarkup
) implements ApiMethodMessage {

public static Builder ofBuilder(String chatId, String fromChatId, long messageId) {
public static Builder ofBuilder(String chatId, String fromChatId, int messageId) {
return new CopyMessage.Builder(chatId, fromChatId, messageId);
}

Expand All @@ -64,16 +67,17 @@ public static class Builder {
private final String chatId;
private int messageThreadId;
private final String fromChatId;
private final long messageId;
private final int messageId;
private String caption;
private ParseMode parseMode;
private MessageEntity[] captionEntities;
private boolean showCaptionAboveMedia;
private boolean disableNotification;
private boolean protectContent;
private ReplyParameters replyParameters;
private ReplyKeyboard replyMarkup;

Builder(String chatId, String fromChatId, long messageId) {
Builder(String chatId, String fromChatId, int messageId) {
this.chatId = chatId;
this.fromChatId = fromChatId;
this.messageId = messageId;
Expand All @@ -99,6 +103,11 @@ public Builder captionEntities(MessageEntity[] captionEntities) {
return this;
}

public Builder showCaptionAboveMedia(boolean showCaptionAboveMedia) {
this.showCaptionAboveMedia = showCaptionAboveMedia;
return this;
}

public Builder disableNotification(boolean disableNotification) {
this.disableNotification = disableNotification;
return this;
Expand All @@ -120,7 +129,7 @@ public Builder replyMarkup(ReplyKeyboard replyMarkup) {
}

public CopyMessage build() {
return new CopyMessage(this.chatId, this.messageThreadId, this.fromChatId, this.messageId, this.caption, this.parseMode, this.captionEntities, this.disableNotification, this.protectContent, this.replyParameters, this.replyMarkup);
return new CopyMessage(this.chatId, this.messageThreadId, this.fromChatId, this.messageId, this.caption, this.parseMode, this.captionEntities, this.showCaptionAboveMedia, this.disableNotification, this.protectContent, this.replyParameters, this.replyMarkup);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public record EditMessageCaption(
@Nullable
MessageEntity[] captionEntities,

@JsonProperty("show_caption_above_media")
boolean showCaptionAboveMedia,

@JsonProperty(value = "reply_markup")
@Nullable
ReplyKeyboard replyMarkup
Expand All @@ -62,6 +65,7 @@ public static class Builder {
private String caption;
private ParseMode parseMode;
private MessageEntity[] captionEntities;
private boolean showCaptionAboveMedia;
private ReplyKeyboard replyMarkup;

public Builder chatId(String chatId) {
Expand Down Expand Up @@ -94,13 +98,18 @@ public Builder captionEntities(MessageEntity[] captionEntities) {
return this;
}

public Builder showCaptionAboveMedia(boolean showCaptionAboveMedia) {
this.showCaptionAboveMedia = showCaptionAboveMedia;
return this;
}

public Builder replyMarkup(ReplyKeyboard replyMarkup) {
this.replyMarkup = replyMarkup;
return this;
}

public EditMessageCaption build() {
return new EditMessageCaption(this.chatId, this.messageId, this.inlineMessageId, this.caption, this.parseMode, this.captionEntities, this.replyMarkup);
return new EditMessageCaption(this.chatId, this.messageId, this.inlineMessageId, this.caption, this.parseMode, this.captionEntities, this.showCaptionAboveMedia, this.replyMarkup);
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package org.teleight.teleightbots.api.methods;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.teleight.teleightbots.api.ApiMethod;
import org.teleight.teleightbots.api.objects.GameHighScore;
import org.teleight.teleightbots.exception.exceptions.TelegramRequestException;

public record GetGameHighScores(
@JsonProperty(value = "user_id", required = true)
long userId,

@JsonProperty("chat_id")
@Nullable
String chatId,

@JsonProperty("message_id")
int messageId,

@JsonProperty("inline_message_id")
@Nullable
String inlineMessageId
) implements ApiMethod<GameHighScore[]> {

public static GetGameHighScores.Builder ofBuilder(long userId) {
return new GetGameHighScores.Builder(userId);
}

@Override
public @NotNull String getEndpointURL() {
return "getGameHighScores";
}

@Override
public GameHighScore @NotNull [] deserializeResponse(@NotNull String answer) throws TelegramRequestException {
return deserializeResponse(answer, GameHighScore[].class);
}

public static class Builder {
private final long userId;
private String chatId;
private int messageId;
private String inlineMessageId;

Builder(long userId) {
this.userId = userId;
}

public Builder chatId(String chatId) {
this.chatId = chatId;
return this;
}

public Builder messageId(int messageId) {
this.messageId = messageId;
return this;
}

public Builder inlineMessageId(String inlineMessageId) {
this.inlineMessageId = inlineMessageId;
return this;
}

public GetGameHighScores build() {
return new GetGameHighScores(this.userId, this.chatId, this.messageId, this.inlineMessageId);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public record SendAnimation(
@Nullable
MessageEntity[] captionEntities,

@JsonProperty("show_caption_above_media")
boolean showCaptionAboveMedia,

@JsonProperty(value = "has_spoiler")
boolean hasSpoiler,

Expand All @@ -63,6 +66,9 @@ public record SendAnimation(
@JsonProperty(value = "protect_content")
boolean protectContent,

@JsonProperty(value = "message_effect_id")
String messageEffectId,

@JsonProperty(value = "reply_parameters")
@Nullable
ReplyParameters replyParameters,
Expand Down Expand Up @@ -94,9 +100,11 @@ public Map<String, Object> getParameters() {
parameters.put("caption", caption);
parameters.put("parse_mode", parseMode);
parameters.put("caption_entities", captionEntities);
parameters.put("show_caption_above_media", showCaptionAboveMedia);
parameters.put("has_spoiler", hasSpoiler);
parameters.put("disable_notification", disableNotification);
parameters.put("protect_content", protectContent);
parameters.put("message_effect_id", messageEffectId);
parameters.put("reply_parameters", replyParameters);
parameters.put("reply_markup", replyMarkup);
return parameters;
Expand All @@ -122,9 +130,11 @@ public static class Builder {
private String caption;
private ParseMode parseMode;
private MessageEntity[] captionEntities;
private boolean showCaptionAboveMedia;
private boolean hasSpoiler;
private boolean disableNotification;
private boolean protectContent;
private String messageEffectId;
private ReplyParameters replyParameters;
private ReplyKeyboard replyMarkup;

Expand Down Expand Up @@ -178,6 +188,11 @@ public Builder captionEntities(MessageEntity[] captionEntities) {
return this;
}

public Builder showCaptionAboveMedia(boolean showCaptionAboveMedia) {
this.showCaptionAboveMedia = showCaptionAboveMedia;
return this;
}

public Builder hasSpoiler(boolean hasSpoiler) {
this.hasSpoiler = hasSpoiler;
return this;
Expand All @@ -193,6 +208,11 @@ public Builder protectContent(boolean protectContent) {
return this;
}

public Builder messageEffectId(String messageEffectId) {
this.messageEffectId = messageEffectId;
return this;
}

public Builder replyParameters(ReplyParameters replyParameters) {
this.replyParameters = replyParameters;
return this;
Expand All @@ -204,7 +224,7 @@ public Builder replyMarkup(ReplyKeyboard replyMarkup) {
}

public SendAnimation build() {
return new SendAnimation(this.businessConnectionId, this.chatId, this.messageThreadId, this.animation, this.duration, this.width, this.height, this.thumbnail, this.caption, this.parseMode, this.captionEntities, this.hasSpoiler, this.disableNotification, this.protectContent, this.replyParameters, this.replyMarkup);
return new SendAnimation(this.businessConnectionId, this.chatId, this.messageThreadId, this.animation, this.duration, this.width, this.height, this.thumbnail, this.caption, this.parseMode, this.captionEntities, this.showCaptionAboveMedia, this.hasSpoiler, this.disableNotification, this.protectContent, this.messageEffectId, this.replyParameters, this.replyMarkup);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public record SendAudio(
@JsonProperty(value = "protect_content")
boolean protectContent,

@JsonProperty(value = "message_effect_id")
String messageEffectId,

@JsonProperty(value = "reply_parameters")
@Nullable
ReplyParameters replyParameters,
Expand Down Expand Up @@ -94,6 +97,7 @@ public Map<String, Object> getParameters() {
parameters.put("title", title);
parameters.put("disable_notification", disableNotification);
parameters.put("protect_content", protectContent);
parameters.put("message_effect_id", messageEffectId);
parameters.put("reply_parameters", replyParameters);
parameters.put("reply_markup", replyMarkup);
return parameters;
Expand Down Expand Up @@ -121,6 +125,7 @@ public static class Builder {
private InputFile thumbnail;
private boolean disableNotification;
private boolean protectContent;
private String messageEffectId;
private ReplyParameters replyParameters;
private ReplyKeyboard replyMarkup;

Expand Down Expand Up @@ -184,6 +189,11 @@ public Builder protectContent(boolean protectContent) {
return this;
}

public Builder messageEffectId(String messageEffectId) {
this.messageEffectId = messageEffectId;
return this;
}

public Builder replyParameters(ReplyParameters replyParameters) {
this.replyParameters = replyParameters;
return this;
Expand All @@ -195,7 +205,7 @@ public Builder replyMarkup(ReplyKeyboard replyMarkup) {
}

public SendAudio build() {
return new SendAudio(this.businessConnectionId, this.chatId, this.messageThreadId, this.audio, this.caption, this.parseMode, this.captionEntities, this.duration, this.performer, this.title, this.thumbnail, this.disableNotification, this.protectContent, this.replyParameters, this.replyMarkup);
return new SendAudio(this.businessConnectionId, this.chatId, this.messageThreadId, this.audio, this.caption, this.parseMode, this.captionEntities, this.duration, this.performer, this.title, this.thumbnail, this.disableNotification, this.protectContent, this.messageEffectId, this.replyParameters, this.replyMarkup);
}
}

Expand Down
Loading
Loading