diff --git a/library/src/main/java/com/pengrad/telegrambot/model/StickerSet.java b/library/src/main/java/com/pengrad/telegrambot/model/StickerSet.java index 355ae9e0..c1a9378b 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/StickerSet.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/StickerSet.java @@ -35,6 +35,10 @@ public Type stickerType() { return sticker_type; } + /** + * @deprecated StickerSets can contain both animated and non-animated stickers since Bot API 7.2 + */ + @Deprecated public Boolean isAnimated() { return is_animated; } @@ -63,6 +67,10 @@ public PhotoSize thumb() { return thumbnail(); } + /** + * @deprecated StickerSets can contain both animated and non-animated stickers since Bot API 7.2 + */ + @Deprecated public Boolean isVideo() { return is_video; } diff --git a/library/src/main/java/com/pengrad/telegrambot/model/request/InputSticker.java b/library/src/main/java/com/pengrad/telegrambot/model/request/InputSticker.java index 22834c2e..f8260286 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/request/InputSticker.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/request/InputSticker.java @@ -1,9 +1,13 @@ package com.pengrad.telegrambot.model.request; +import com.google.gson.annotations.SerializedName; import com.pengrad.telegrambot.AttachName; import com.pengrad.telegrambot.model.MaskPosition; +import com.pengrad.telegrambot.model.Sticker; import java.io.Serializable; +import java.util.Arrays; +import java.util.Objects; public class InputSticker implements Serializable { @@ -13,6 +17,7 @@ public class InputSticker implements Serializable { private String[] emoji_list; private MaskPosition mask_position; private String[] keywords; + private Sticker.Format format; transient private String attachName; transient private Object attach; @@ -45,4 +50,43 @@ public InputSticker keywords(String[] keywords) { return this; } + public InputSticker format(Sticker.Format format) { + this.format = format; + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof InputSticker)) return false; + InputSticker that = (InputSticker) o; + return Objects.equals(sticker, that.sticker) + && Arrays.equals(emoji_list, that.emoji_list) + && Objects.equals(mask_position, that.mask_position) + && Arrays.equals(keywords, that.keywords) + && Objects.equals(format, that.format) + && Objects.equals(attachName, that.attachName) + && Objects.equals(attach, that.attach); + } + + @Override + public int hashCode() { + int result = Objects.hash(sticker, mask_position, format, attachName, attach); + result = 31 * result + Arrays.hashCode(emoji_list); + result = 31 * result + Arrays.hashCode(keywords); + return result; + } + + @Override + public String toString() { + return "InputSticker{" + + "sticker='" + sticker + '\'' + + ", emoji_list=" + Arrays.toString(emoji_list) + + ", mask_position=" + mask_position + + ", keywords=" + Arrays.toString(keywords) + + ", format=" + format + + ", attachName='" + attachName + '\'' + + ", attach=" + attach + + '}'; + } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/CreateNewStickerSet.java b/library/src/main/java/com/pengrad/telegrambot/request/CreateNewStickerSet.java index 599b3671..a8e6e3c4 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/CreateNewStickerSet.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/CreateNewStickerSet.java @@ -57,6 +57,23 @@ private CreateNewStickerSet(Long userId, String name, String title, String emoji add("emojis", emojis); } + public CreateNewStickerSet(Long userId, String name, String title, InputSticker[] stickers) { + super(BaseResponse.class); + add("user_id", userId); + add("name", name); + add("title", title); + add("stickers", stickers); + for (InputSticker sticker : stickers) { + if (sticker.getAttachment() != null) { + add(sticker.getAttachName(), sticker.getAttachment()); + } + } + } + + /** + * @deprecated StickerSets can contain both animated and non-animated stickers since Bot API 7.2 so Sticker Format argument was removed + */ + @Deprecated public CreateNewStickerSet(Long userId, String name, String title, InputSticker[] stickers, Format stickerFormat) { super(BaseResponse.class); add("user_id", userId); diff --git a/library/src/main/java/com/pengrad/telegrambot/request/ReplaceStickerInSet.java b/library/src/main/java/com/pengrad/telegrambot/request/ReplaceStickerInSet.java new file mode 100644 index 00000000..b9b96922 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/request/ReplaceStickerInSet.java @@ -0,0 +1,16 @@ +package com.pengrad.telegrambot.request; + +import com.pengrad.telegrambot.model.request.InputSticker; +import com.pengrad.telegrambot.response.BaseResponse; + +public class ReplaceStickerInSet extends BaseRequest { + + public ReplaceStickerInSet(Long userId, String name, String oldSticker, InputSticker sticker) { + super(BaseResponse.class); + add("user_id", userId); + add("name", name); + add("old_sticker", oldSticker); + add("sticker", sticker); + } + +} diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetStickerSetThumbnail.java b/library/src/main/java/com/pengrad/telegrambot/request/SetStickerSetThumbnail.java index 18cc20e7..7f3e5183 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetStickerSetThumbnail.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetStickerSetThumbnail.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.model.Sticker; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -8,14 +9,36 @@ */ public class SetStickerSetThumbnail extends AbstractUploadRequest { + /** + * @deprecated Format parameter is required since Bot API 7.2 + */ + @Deprecated public SetStickerSetThumbnail(String name, Long userId, Object thumbnail) { super(BaseResponse.class, "thumbnail", thumbnail); add("name", name); add("user_id", userId); } + /** + * @deprecated Format parameter is required since Bot API 7.2 + */ + @Deprecated public SetStickerSetThumbnail(String name, Long userId) { super(BaseResponse.class, "name", name); add("user_id", userId); } + + public SetStickerSetThumbnail(String name, Long userId, Object thumbnail, Sticker.Format format) { + super(BaseResponse.class, "thumbnail", thumbnail); + add("name", name); + add("user_id", userId); + add("format", format); + } + + public SetStickerSetThumbnail(String name, Long userId, Sticker.Format format) { + super(BaseResponse.class, "name", name); + add("user_id", userId); + add("format", format); + } + }