From b08e59dbff3fdb631cc5821bfed0c8797f64e9de Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Mon, 19 Aug 2024 19:53:48 +0200 Subject: [PATCH 1/9] Added the parameter business_connection_id to the method sendPaidMedia --- .../java/com/pengrad/telegrambot/request/SendPaidMedia.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendPaidMedia.java b/library/src/main/java/com/pengrad/telegrambot/request/SendPaidMedia.java index b5804650..d8e81dd1 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendPaidMedia.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendPaidMedia.java @@ -44,6 +44,10 @@ public SendPaidMedia replyParameters(ReplyParameters replyParameters) { return add("reply_parameters", replyParameters); } + public SendPaidMedia businessConnectionId(String businessConnectionId) { + return add("business_connection_id", businessConnectionId); + } + public SendPaidMedia replyMarkup(InlineKeyboardMarkup replyMarkup) { return add("reply_markup", replyMarkup); } From b7fe62e57caeaad8a27a49d771f44700ee25894f Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Mon, 19 Aug 2024 19:56:54 +0200 Subject: [PATCH 2/9] Added the field paid_media to the class TransactionPartnerUser --- .../model/stars/partner/TransactionPartnerUser.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/com/pengrad/telegrambot/model/stars/partner/TransactionPartnerUser.java b/library/src/main/java/com/pengrad/telegrambot/model/stars/partner/TransactionPartnerUser.java index 86b931e6..8d2cab99 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/stars/partner/TransactionPartnerUser.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/stars/partner/TransactionPartnerUser.java @@ -2,6 +2,7 @@ import com.pengrad.telegrambot.model.User; import com.pengrad.telegrambot.model.chatbackground.BackgroundFillFreeformGradient; +import com.pengrad.telegrambot.model.paidmedia.PaidMedia; import java.util.Arrays; import java.util.Objects; @@ -12,6 +13,7 @@ public class TransactionPartnerUser extends TransactionPartner { private User user; private String invoice_payload; + private PaidMedia[] paid_media; public TransactionPartnerUser() { super(TYPE); @@ -25,6 +27,10 @@ public String invoicePayload() { return invoice_payload; } + public PaidMedia[] paidMedia() { + return paid_media; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -32,7 +38,8 @@ public boolean equals(Object o) { TransactionPartnerUser that = (TransactionPartnerUser) o; return Objects.equals(type(), that.type()) && Objects.equals(user, that.user) && - Objects.equals(invoice_payload, that.invoice_payload); + Objects.equals(invoice_payload, that.invoice_payload) && + Objects.equals(paid_media, that.paid_media); } @Override @@ -45,7 +52,8 @@ public String toString() { return "TransactionPartnerUser{" + "type='" + type() + "\'," + ", user=" + user + "\'," + - ", invoice_payload=" + invoice_payload + "\'" + + ", invoice_payload=" + invoice_payload + "\'," + + ", paid_media=" + paid_media + "\'" + '}'; } From 0cd10f3121db8c59359559a8fdcd8793d2b1f1c6 Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Mon, 19 Aug 2024 20:02:50 +0200 Subject: [PATCH 3/9] Added the method createChatSubscriptionInviteLink --- .../CreateChatSubscriptionInviteLink.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 library/src/main/java/com/pengrad/telegrambot/request/CreateChatSubscriptionInviteLink.java diff --git a/library/src/main/java/com/pengrad/telegrambot/request/CreateChatSubscriptionInviteLink.java b/library/src/main/java/com/pengrad/telegrambot/request/CreateChatSubscriptionInviteLink.java new file mode 100644 index 00000000..b1d14d9a --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/request/CreateChatSubscriptionInviteLink.java @@ -0,0 +1,34 @@ +package com.pengrad.telegrambot.request; + +import com.pengrad.telegrambot.response.ChatInviteLinkResponse; + +/** + * Stas Parshin + * 10 March 2021 + */ +public class CreateChatSubscriptionInviteLink extends BaseRequest { + + /** + * Create a subscription invite link for a channel chat. + * + * @param chatId Unique identifier for the target channel chat or username of the target channel (in the format @channelusername) + * @param subscriptionPeriod The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days). + * @param subscriptionPrice The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500 + */ + public CreateChatSubscriptionInviteLink(Object chatId, Integer subscriptionPeriod, Integer subscriptionPrice) { + super(ChatInviteLinkResponse.class); + add("chat_id", chatId); + add("subscription_period", subscriptionPeriod); + add("subscription_price", subscriptionPrice); + } + + /** + * + * @param name Invite link name; 0-32 characters + */ + public CreateChatSubscriptionInviteLink name(String name) { + return add("name", name); + } + + +} From 92608aa36af291f53204ba5f80cc6789e4048f54 Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Mon, 19 Aug 2024 20:03:00 +0200 Subject: [PATCH 4/9] Added the method editChatSubscriptionInviteLink --- .../EditChatSubscriptionInviteLink.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 library/src/main/java/com/pengrad/telegrambot/request/EditChatSubscriptionInviteLink.java diff --git a/library/src/main/java/com/pengrad/telegrambot/request/EditChatSubscriptionInviteLink.java b/library/src/main/java/com/pengrad/telegrambot/request/EditChatSubscriptionInviteLink.java new file mode 100644 index 00000000..deae7d59 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/request/EditChatSubscriptionInviteLink.java @@ -0,0 +1,31 @@ +package com.pengrad.telegrambot.request; + +import com.pengrad.telegrambot.response.ChatInviteLinkResponse; + +/** + * Stas Parshin + * 10 March 2021 + */ +public class EditChatSubscriptionInviteLink extends BaseRequest { + + /** + * Edit a subscription invite link created by the bot + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param inviteLink The invite link to edit + */ + public EditChatSubscriptionInviteLink(Object chatId, String inviteLink) { + super(ChatInviteLinkResponse.class); + add("chat_id", chatId); + add("invite_link", inviteLink); + } + + /** + * + * @param name Invite link name; 0-32 characters + * @return + */ + public EditChatSubscriptionInviteLink name(String name) { + return add("name", name); + } + +} From feec079ebd551d36c5c73aefe2f3e873273f3c38 Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Mon, 19 Aug 2024 20:08:53 +0200 Subject: [PATCH 5/9] Added support for paid reactions and the class ReactionTypePaid --- .../reaction/ReactionTypeCustomEmoji.java | 2 +- .../model/reaction/ReactionTypeEmoji.java | 2 +- .../model/reaction/ReactionTypePaid.java | 27 +++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 library/src/main/java/com/pengrad/telegrambot/model/reaction/ReactionTypePaid.java diff --git a/library/src/main/java/com/pengrad/telegrambot/model/reaction/ReactionTypeCustomEmoji.java b/library/src/main/java/com/pengrad/telegrambot/model/reaction/ReactionTypeCustomEmoji.java index e77b1f35..9c8f5c58 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/reaction/ReactionTypeCustomEmoji.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/reaction/ReactionTypeCustomEmoji.java @@ -38,7 +38,7 @@ public int hashCode() { public String toString() { return "ReactionTypeCustomEmoji{" + "type='" + type() + '\'' + - "custom_emoji_id='" + custom_emoji_id + '\'' + + ",custom_emoji_id='" + custom_emoji_id + '\'' + '}'; } } diff --git a/library/src/main/java/com/pengrad/telegrambot/model/reaction/ReactionTypeEmoji.java b/library/src/main/java/com/pengrad/telegrambot/model/reaction/ReactionTypeEmoji.java index 91d6faae..663f6e25 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/reaction/ReactionTypeEmoji.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/reaction/ReactionTypeEmoji.java @@ -38,7 +38,7 @@ public int hashCode() { public String toString() { return "ReactionTypeEmoji{" + "type='" + type() + '\'' + - "emoji='" + emoji + '\'' + + ",emoji='" + emoji + '\'' + '}'; } } diff --git a/library/src/main/java/com/pengrad/telegrambot/model/reaction/ReactionTypePaid.java b/library/src/main/java/com/pengrad/telegrambot/model/reaction/ReactionTypePaid.java new file mode 100644 index 00000000..df8251a7 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/reaction/ReactionTypePaid.java @@ -0,0 +1,27 @@ +package com.pengrad.telegrambot.model.reaction; + +import java.util.Objects; + +public class ReactionTypePaid extends ReactionType { + + public static final String EMOJI_TYPE = "paid"; + + public ReactionTypePaid() { + super(EMOJI_TYPE); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + return true; + } + + @Override + public String toString() { + return "ReactionTypePaid{" + + "type='" + type() + '\'' + + '}'; + } +} From cda7109fd92391d32c7056fc8681deaa11274f67 Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Mon, 19 Aug 2024 20:09:59 +0200 Subject: [PATCH 6/9] Bump version to 7.9 --- README.md | 6 +++--- README_RU.md | 6 +++--- gradle.properties | 2 +- pom.xml | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1efbb193..240a31c4 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![codecov](https://codecov.io/gh/pengrad/java-telegram-bot-api/branch/master/graph/badge.svg)](https://codecov.io/gh/pengrad/java-telegram-bot-api) Java library for interacting with [Telegram Bot API](https://core.telegram.org/bots/api) -- Full support of all Bot API 7.8 methods +- Full support of all Bot API 7.9 methods - Telegram [Passport](https://core.telegram.org/passport) and Decryption API - Bot [Payments](https://core.telegram.org/bots/payments) - [Gaming Platform](https://telegram.org/blog/games) @@ -13,14 +13,14 @@ Java library for interacting with [Telegram Bot API](https://core.telegram.org/b Gradle: ```groovy -implementation 'com.github.pengrad:java-telegram-bot-api:7.8.0' +implementation 'com.github.pengrad:java-telegram-bot-api:7.9.0' ``` Maven: ```xml com.github.pengrad java-telegram-bot-api - 7.8.0 + 7.9.0 ``` [JAR with all dependencies on release page](https://github.com/pengrad/java-telegram-bot-api/releases) diff --git a/README_RU.md b/README_RU.md index 441cb57b..b16717d4 100644 --- a/README_RU.md +++ b/README_RU.md @@ -4,7 +4,7 @@ [![codecov](https://codecov.io/gh/pengrad/java-telegram-bot-api/branch/master/graph/badge.svg)](https://codecov.io/gh/pengrad/java-telegram-bot-api) Java библиотека, созданная для работы с [Telegram Bot API](https://core.telegram.org/bots/api) -- Полная поддержка всех методов BOT API 7.8 +- Полная поддержка всех методов BOT API 7.9 - Поддержка Telegram [паспорта](https://core.telegram.org/passport) и дешифровки (Decryption API); - Поддержка [платежей](https://core.telegram.org/bots/payments); - [Игровая платформа](https://telegram.org/blog/games). @@ -13,14 +13,14 @@ Java библиотека, созданная для работы с [Telegram B Gradle: ```groovy -implementation 'com.github.pengrad:java-telegram-bot-api:7.8.0' +implementation 'com.github.pengrad:java-telegram-bot-api:7.9.0' ``` Maven: ```xml com.github.pengrad java-telegram-bot-api - 7.8.0 + 7.9.0 ``` Также JAR со всеми зависимостями можно найти [в релизах](https://github.com/pengrad/java-telegram-bot-api/releases). diff --git a/gradle.properties b/gradle.properties index a28484c3..1f3caea1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.github.pengrad -VERSION_NAME=7.8.0 +VERSION_NAME=7.9.0 POM_DESCRIPTION=Java API for Telegram Bot API POM_URL=https://github.com/pengrad/java-telegram-bot-api/ diff --git a/pom.xml b/pom.xml index 65a12516..4d73671b 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 4.0.0 com.github.pengrad java-telegram-bot-api - 7.8.0 + 7.9.0 JavaTelegramBotApi Java API for Telegram Bot API https://github.com/pengrad/java-telegram-bot-api/ From 7c4f4e14bf4d9a722fdf5c37fd084228e875b304 Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Mon, 19 Aug 2024 22:39:39 +0200 Subject: [PATCH 7/9] Fix ReactionTypeAdapter --- .../pengrad/telegrambot/model/reaction/ReactionTypePaid.java | 4 ++-- .../pengrad/telegrambot/utility/gson/ReactionTypeAdapter.java | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/com/pengrad/telegrambot/model/reaction/ReactionTypePaid.java b/library/src/main/java/com/pengrad/telegrambot/model/reaction/ReactionTypePaid.java index df8251a7..d364ac83 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/reaction/ReactionTypePaid.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/reaction/ReactionTypePaid.java @@ -4,10 +4,10 @@ public class ReactionTypePaid extends ReactionType { - public static final String EMOJI_TYPE = "paid"; + public static final String PAID_TYPE = "paid"; public ReactionTypePaid() { - super(EMOJI_TYPE); + super(PAID_TYPE); } @Override diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/gson/ReactionTypeAdapter.java b/library/src/main/java/com/pengrad/telegrambot/utility/gson/ReactionTypeAdapter.java index a175ff89..ead443d3 100644 --- a/library/src/main/java/com/pengrad/telegrambot/utility/gson/ReactionTypeAdapter.java +++ b/library/src/main/java/com/pengrad/telegrambot/utility/gson/ReactionTypeAdapter.java @@ -4,6 +4,7 @@ import com.pengrad.telegrambot.model.reaction.ReactionType; import com.pengrad.telegrambot.model.reaction.ReactionTypeCustomEmoji; import com.pengrad.telegrambot.model.reaction.ReactionTypeEmoji; +import com.pengrad.telegrambot.model.reaction.ReactionTypePaid; import java.lang.reflect.Type; @@ -19,6 +20,8 @@ public ReactionType deserialize(JsonElement element, Type type, JsonDeserializat return context.deserialize(object, ReactionTypeEmoji.class); } else if (ReactionTypeCustomEmoji.CUSTOM_EMOJI_TYPE.equals(discriminator)) { return context.deserialize(object, ReactionTypeCustomEmoji.class); + } else if (ReactionTypePaid.PAID_TYPE.equals(discriminator)) { + return context.deserialize(object, ReactionTypeCustomEmoji.class); } return new ReactionType(discriminator); From 0d9fd3d96bed72ef5f80cd24bbe40cc0d9b3ef67 Mon Sep 17 00:00:00 2001 From: Mirco Ianese Date: Mon, 19 Aug 2024 22:48:14 +0200 Subject: [PATCH 8/9] Fix BackgroundFill class extensions --- .../model/chatbackground/BackgroundFillFreeformGradient.java | 2 +- .../model/chatbackground/BackgroundFillGradient.java | 2 +- .../telegrambot/model/chatbackground/BackgroundFillSolid.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundFillFreeformGradient.java b/library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundFillFreeformGradient.java index d21395a1..a13ca915 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundFillFreeformGradient.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundFillFreeformGradient.java @@ -2,7 +2,7 @@ import java.util.Arrays; -public class BackgroundFillFreeformGradient extends BackgroundType { +public class BackgroundFillFreeformGradient extends BackgroundFill { public static final String TYPE = "freeform_gradient"; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundFillGradient.java b/library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundFillGradient.java index 4f4ca482..6f79e8d6 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundFillGradient.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundFillGradient.java @@ -2,7 +2,7 @@ import java.util.Objects; -public class BackgroundFillGradient extends BackgroundType { +public class BackgroundFillGradient extends BackgroundFill { public static final String TYPE = "gradient"; diff --git a/library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundFillSolid.java b/library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundFillSolid.java index 5353b0b1..7d9de04d 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundFillSolid.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundFillSolid.java @@ -2,7 +2,7 @@ import java.util.Objects; -public class BackgroundFillSolid extends BackgroundType { +public class BackgroundFillSolid extends BackgroundFill { public static final String TYPE = "solid"; From 742a40164eee1dd041dccaeb8fe840ee0c3832a9 Mon Sep 17 00:00:00 2001 From: Stas Parshin <2172170+pengrad@users.noreply.github.com> Date: Tue, 20 Aug 2024 18:42:26 +0700 Subject: [PATCH 9/9] Fix TransactionPartnerUser.hashCode(), ReactionTypeAdapter --- .../model/stars/partner/TransactionPartnerUser.java | 8 +++----- .../telegrambot/utility/gson/ReactionTypeAdapter.java | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/library/src/main/java/com/pengrad/telegrambot/model/stars/partner/TransactionPartnerUser.java b/library/src/main/java/com/pengrad/telegrambot/model/stars/partner/TransactionPartnerUser.java index 8d2cab99..391764d2 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/stars/partner/TransactionPartnerUser.java +++ b/library/src/main/java/com/pengrad/telegrambot/model/stars/partner/TransactionPartnerUser.java @@ -35,16 +35,14 @@ public PaidMedia[] paidMedia() { public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; TransactionPartnerUser that = (TransactionPartnerUser) o; - return Objects.equals(type(), that.type()) && - Objects.equals(user, that.user) && - Objects.equals(invoice_payload, that.invoice_payload) && - Objects.equals(paid_media, that.paid_media); + return Objects.equals(user, that.user) && Objects.equals(invoice_payload, that.invoice_payload) && Objects.deepEquals(paid_media, that.paid_media); } @Override public int hashCode() { - return Objects.hash(type(), user, invoice_payload); + return Objects.hash(super.hashCode(), user, invoice_payload, Arrays.hashCode(paid_media)); } @Override diff --git a/library/src/main/java/com/pengrad/telegrambot/utility/gson/ReactionTypeAdapter.java b/library/src/main/java/com/pengrad/telegrambot/utility/gson/ReactionTypeAdapter.java index ead443d3..d8759f0e 100644 --- a/library/src/main/java/com/pengrad/telegrambot/utility/gson/ReactionTypeAdapter.java +++ b/library/src/main/java/com/pengrad/telegrambot/utility/gson/ReactionTypeAdapter.java @@ -21,7 +21,7 @@ public ReactionType deserialize(JsonElement element, Type type, JsonDeserializat } else if (ReactionTypeCustomEmoji.CUSTOM_EMOJI_TYPE.equals(discriminator)) { return context.deserialize(object, ReactionTypeCustomEmoji.class); } else if (ReactionTypePaid.PAID_TYPE.equals(discriminator)) { - return context.deserialize(object, ReactionTypeCustomEmoji.class); + return context.deserialize(object, ReactionTypePaid.class); } return new ReactionType(discriminator);