Skip to content

Commit

Permalink
Api Version 7.10
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenlagus committed Sep 7, 2024
1 parent 6fc8aca commit aee0b6a
Show file tree
Hide file tree
Showing 24 changed files with 149 additions and 32 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<packaging>pom</packaging>
<version>7.9.1</version>
<version>7.10.0</version>

<modules>
<module>telegrambots-meta</module>
Expand Down
6 changes: 3 additions & 3 deletions telegrambots-abilities/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>7.9.1</version>
<version>7.10.0</version>
</parent>

<artifactId>telegrambots-abilities</artifactId>
Expand Down Expand Up @@ -104,12 +104,12 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-webhook</artifactId>
<version>7.9.1</version>
<version>7.10.0</version>
</dependency>
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-longpolling</artifactId>
<version>7.9.1</version>
<version>7.10.0</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public enum Flag implements Predicate<Update> {
HAS_BUSINESS_MESSAGE(Update::hasBusinessMessage),
HAS_EDITED_BUSINESS_MESSAGE(Update::hasEditedBusinessMessage),
HAS_DELETED_BUSINESS_MESSAGE(Update::hasDeletedBusinessMessage),
HAS_PAID_MEDIA_PURCHASED(Update::hasPaidMediaPurchased),


// Message Flags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ private static User getUserElseThrow(Update update) {
return update.getEditedBuinessMessage().getFrom();
} else if (Flag.HAS_DELETED_BUSINESS_MESSAGE.test(update)) {
return EMPTY_USER;
}else if (Flag.HAS_PAID_MEDIA_PURCHASED.test(update)) {
return update.getPaidMediaPurchased().getUser();
} else if (Flag.POLL.test(update)) {
return EMPTY_USER;
} else {
Expand Down Expand Up @@ -191,6 +193,8 @@ public static Long getChatId(Update update) {
return update.getEditedBuinessMessage().getFrom().getId();
} else if (Flag.HAS_DELETED_BUSINESS_MESSAGE.test(update)) {
return EMPTY_USER.getId();
} else if (Flag.HAS_PAID_MEDIA_PURCHASED.test(update)) {
return update.getPaidMediaPurchased().getUser().getId();
} else {
throw new IllegalStateException("Could not retrieve originating chat ID from update");
}
Expand Down
2 changes: 1 addition & 1 deletion telegrambots-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>7.9.1</version>
<version>7.10.0</version>
</parent>

<name>Telegram Bots Client</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ public CompletableFuture<List<Message>> executeAsync(SendPaidMedia sendPaidMedia
.addPart(SendPaidMedia.DISABLE_NOTIFICATION_FIELD, sendPaidMedia.getDisableNotification())
.addPart(SendPaidMedia.PROTECT_CONTENT_FIELD, sendPaidMedia.getProtectContent())
.addPart(SendPaidMedia.BUSINESS_CONNECTION_ID_FIELD, sendPaidMedia.getBusinessConnectionId())
.addPart(SendPaidMedia.PAYLOAD_FIELD, sendPaidMedia.getPayload())
.addJsonPart(SendPaidMedia.CAPTION_ENTITIES_FIELD, sendPaidMedia.getCaptionEntities())
.addJsonPart(SendPaidMedia.REPLY_MARKUP_FIELD, sendPaidMedia.getReplyMarkup())
.addJsonPart(SendPaidMedia.REPLY_PARAMETERS_FIELD, sendPaidMedia.getReplyParameters());
Expand Down
4 changes: 2 additions & 2 deletions telegrambots-extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ Just import add the library to your project with one of these options:
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-extensions</artifactId>
<version>7.9.1</version>
<version>7.10.0</version>
</dependency>
```

2. Using Gradle:

```gradle
implementation 'org.telegram:telegrambots-extensions:7.9.1'
implementation 'org.telegram:telegrambots-extensions:7.10.0'
```
6 changes: 3 additions & 3 deletions telegrambots-extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>7.9.1</version>
<version>7.10.0</version>
</parent>

<artifactId>telegrambots-extensions</artifactId>
Expand Down Expand Up @@ -89,12 +89,12 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-webhook</artifactId>
<version>7.9.1</version>
<version>7.10.0</version>
</dependency>
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-longpolling</artifactId>
<version>7.9.1</version>
<version>7.10.0</version>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion telegrambots-longpolling/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>7.9.1</version>
<version>7.10.0</version>
</parent>

<artifactId>telegrambots-longpolling</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion telegrambots-meta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>7.9.1</version>
<version>7.10.0</version>
</parent>

<artifactId>telegrambots-meta</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class SendPaidMedia extends PartialBotApiMethod<ArrayList<Message>> {
public static final String REPLY_PARAMETERS_FIELD = "reply_parameters";
public static final String REPLY_MARKUP_FIELD = "reply_markup";
public static final String BUSINESS_CONNECTION_ID_FIELD = "business_connection_id";
public static final String PAYLOAD_FIELD = "payload";

/**
* Unique identifier for the target chat or username of the target channel (in the format @channelusername).
Expand Down Expand Up @@ -119,6 +120,12 @@ public class SendPaidMedia extends PartialBotApiMethod<ArrayList<Message>> {
* Unique identifier of the business connection on behalf of which the message will be sent
*/
private String businessConnectionId;
/**
* Optional
* Bot-defined paid media payload, 0-128 bytes.
* This will not be displayed to the user, use it for your internal processes.
*/
private String payload;

@Tolerate
public void setChatId(@NonNull Long chatId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.telegram.telegrambots.meta.api.objects.inlinequery.ChosenInlineQuery;
import org.telegram.telegrambots.meta.api.objects.inlinequery.InlineQuery;
import org.telegram.telegrambots.meta.api.objects.message.Message;
import org.telegram.telegrambots.meta.api.objects.payments.PaidMediaPurchased;
import org.telegram.telegrambots.meta.api.objects.payments.PreCheckoutQuery;
import org.telegram.telegrambots.meta.api.objects.payments.ShippingQuery;
import org.telegram.telegrambots.meta.api.objects.polls.Poll;
Expand Down Expand Up @@ -59,6 +60,7 @@ public class Update implements BotApiObject {
private static final String BUSINESS_MESSAGE_FIELD = "business_message";
private static final String EDITED_BUSINESS_MESSAGE_FIELD = "edited_business_message";
private static final String DELETED_BUSINESS_MESSAGES_FIELD = "deleted_business_messages";
private static final String PURCHASED_PAID_MEDIA_FIELD = "purchased_paid_media";

@JsonProperty(UPDATEID_FIELD)
private Integer updateId;
Expand Down Expand Up @@ -201,6 +203,12 @@ public class Update implements BotApiObject {
*/
@JsonProperty(DELETED_BUSINESS_MESSAGES_FIELD)
private BusinessMessagesDeleted deletedBusinessMessages;
/**
* Optional.
* A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat
*/
@JsonProperty(PURCHASED_PAID_MEDIA_FIELD)
private PaidMediaPurchased paidMediaPurchased;

public boolean hasMessage() {
return message != null;
Expand Down Expand Up @@ -273,4 +281,8 @@ public boolean hasEditedBusinessMessage() {
public boolean hasDeletedBusinessMessage() {
return deletedBusinessMessages != null;
}

public boolean hasPaidMediaPurchased() {
return paidMediaPurchased != null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
/**
* @author Ruben Bermudez
* @version 7.0
* The boost was obtained by the creation of a Telegram Premium giveaway.
* This boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription.
* The boost was obtained by the creation of a Telegram Premium or a Telegram Star giveaway.
* This boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription for
* Telegram Premium giveaways and prize_star_count / 500 times for one year for Telegram Star giveaways.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
Expand All @@ -33,6 +34,7 @@ public class ChatBoostSourceGiveaway implements ChatBoostSource {
private static final String GIVEAWAY_MESSAGE_ID_FIELD = "giveaway_message_id";
private static final String USER_FIELD = "user";
private static final String IS_UNCLAIMED_FIELD = "is_unclaimed";
private static final String PRIZE_STAR_COUNT_FIELD = "prize_star_count";

/**
* Source of the boost, always “giveaway”
Expand All @@ -48,7 +50,7 @@ public class ChatBoostSourceGiveaway implements ChatBoostSource {
private Integer giveawayMessageId;
/**
* Optional.
* User that won the prize in the giveaway if any
* User that won the prize in the giveaway if any; for Telegram Premium giveaways only
*/
@JsonProperty(USER_FIELD)
private User user;
Expand All @@ -58,4 +60,10 @@ public class ChatBoostSourceGiveaway implements ChatBoostSource {
*/
@JsonProperty(IS_UNCLAIMED_FIELD)
private Boolean isUnclaimed;
/**
* Optional.
* The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
*/
@JsonProperty(PRIZE_STAR_COUNT_FIELD)
private Integer prizeStarCount;
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class Giveaway implements BotApiObject {
public static final String PRIZE_DESCRIPTION_FIELD = "prize_description";
public static final String COUNTRY_CODES_FIELD = "country_codes";
public static final String PREMIUM_SUBSCRIPTION_MONTH_COUNT_FIELD = "premium_subscription_month_count";
public static final String PRIZE_STAR_COUNT_FIELD = "prize_star_count";

/**
* The list of chats which the user must join to participate in the giveaway
Expand Down Expand Up @@ -83,9 +84,15 @@ public class Giveaway implements BotApiObject {
private List<String> countryCodes;
/**
* Optional.
* The number of months the Telegram Premium subscription won from the giveaway will be active for
* The number of months the Telegram Premium subscription won from the giveaway will be active for;
* for Telegram Premium giveaways only
*/
@JsonProperty(PREMIUM_SUBSCRIPTION_MONTH_COUNT_FIELD)
private Integer premiumSubscriptionMonthCount;

/**
* Optional.
* The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
*/
@JsonProperty(PRIZE_STAR_COUNT_FIELD)
private Integer prizeStarCount;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class GiveawayCompleted implements BotApiObject {
public static final String WINNER_COUNT_FIELD = "winner_count";
public static final String UNCLAIMED_PRIZE_COUNT_FIELD = "unclaimed_prize_count";
public static final String GIVEAWAY_MESSAGE_FIELD = "giveaway_message";
public static final String IS_STAR_GIVEAWAY_FIELD = "is_star_giveaway";

/**
* Number of winners in the giveaway
Expand All @@ -50,4 +51,11 @@ public class GiveawayCompleted implements BotApiObject {
*/
@JsonProperty(GIVEAWAY_MESSAGE_FIELD)
private Message giveawayMessage;
/**
* Optional.
* True, if the giveaway is a Telegram Star giveaway.
* Otherwise, currently, the giveaway is a Telegram Premium giveaway.
*/
@JsonProperty(IS_STAR_GIVEAWAY_FIELD)
private Boolean isStarGiveaway;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.telegram.telegrambots.meta.api.objects.giveaway;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
Expand All @@ -14,8 +15,6 @@
* @author Ruben Bermudez
* @version 7.0
* This object represents a service message about the creation of a scheduled giveaway.
*
* Currently holds no information.
*/

@EqualsAndHashCode(callSuper = false)
Expand All @@ -27,4 +26,12 @@
@Jacksonized
@JsonIgnoreProperties(ignoreUnknown = true)
public class GiveawayCreated implements BotApiObject {
private static final String PRIZE_STAR_COUNT_FIELD = "prize_star_count";

/**
* Optional.
* The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
*/
@JsonProperty(PRIZE_STAR_COUNT_FIELD)
private Integer prizeStarCount;
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class GiveawayWinners implements BotApiObject {
public static final String ONLY_NEW_MEMBERS_FIELD = "only_new_members";
public static final String WAS_REFUNDED_FIELD = "was_refunded";
public static final String PRIZE_DESCRIPTION_FIELD = "prize_description";
public static final String PRIZE_STAR_COUNT_FIELD = "prize_star_count";

/**
* The chat that created the giveaway
Expand Down Expand Up @@ -77,7 +78,8 @@ public class GiveawayWinners implements BotApiObject {
private Integer additionalChatCount;
/**
* Optional.
* The number of months the Telegram Premium subscription won from the giveaway will be active for
* The number of months the Telegram Premium subscription won from the giveaway will be active for;
* for Telegram Premium giveaways only
*/
@JsonProperty(PREMIUM_SUBSCRIPTION_MONTH_COUNT_FIELD)
private Integer premiumSubscriptionMonthCount;
Expand Down Expand Up @@ -105,7 +107,11 @@ public class GiveawayWinners implements BotApiObject {
*/
@JsonProperty(PRIZE_DESCRIPTION_FIELD)
private String prizeDescription;



/**
* Optional.
* The number of Telegram Stars that were split between giveaway winners;
* for Telegram Star giveaways only
*/
@JsonProperty(PRIZE_STAR_COUNT_FIELD)
private Integer prizeStarCount;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ public class LabeledPrice implements Validable, BotApiObject {
private static final String LABEL_FIELD = "label";
private static final String AMOUNT_FIELD = "amount";

/**
* Portion label
*/
@JsonProperty(LABEL_FIELD)
@NonNull
private String label; ///< Portion label
private String label;
/**
* Price of the product in the smallest units of the currency (integer, not float/double).
* For example, for a price of US$ 1.45 pass amount = 145.
Expand All @@ -44,10 +47,10 @@ public class LabeledPrice implements Validable, BotApiObject {

@Override
public void validate() throws TelegramApiValidationException {
if (label == null || label.isEmpty()) {
if (label.isEmpty()) {
throw new TelegramApiValidationException("Label parameter can't be empty", this);
}
if (amount == null) {
if (amount < 0) {
throw new TelegramApiValidationException("Amount parameter can't be empty", this);
}
}
Expand Down
Loading

0 comments on commit aee0b6a

Please sign in to comment.