Skip to content

Commit

Permalink
Api Version 7.9
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenlagus committed Aug 18, 2024
1 parent d7f4a74 commit 5fc7d88
Show file tree
Hide file tree
Showing 21 changed files with 420 additions and 118 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.8.0</version>
<version>7.9.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.8.0</version>
<version>7.9.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.8.0</version>
<version>7.9.0</version>
</dependency>
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-longpolling</artifactId>
<version>7.8.0</version>
<version>7.9.0</version>
</dependency>

<dependency>
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.8.0</version>
<version>7.9.0</version>
</parent>

<name>Telegram Bots Client</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ public CompletableFuture<List<Message>> executeAsync(SendPaidMedia sendPaidMedia
.addPart(SendPaidMedia.SHOW_CAPTION_ABOVE_MEDIA_FIELD, sendPaidMedia.getShowCaptionAboveMedia())
.addPart(SendPaidMedia.DISABLE_NOTIFICATION_FIELD, sendPaidMedia.getDisableNotification())
.addPart(SendPaidMedia.PROTECT_CONTENT_FIELD, sendPaidMedia.getProtectContent())
.addPart(SendPaidMedia.BUSINESS_CONNECTION_ID_FIELD, sendPaidMedia.getBusinessConnectionId())
.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.8.0</version>
<version>7.9.0</version>
</dependency>
```

2. Using Gradle:

```gradle
implementation 'org.telegram:telegrambots-extensions:7.8.0'
implementation 'org.telegram:telegrambots-extensions:7.9.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.8.0</version>
<version>7.9.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.8.0</version>
<version>7.9.0</version>
</dependency>
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-longpolling</artifactId>
<version>7.8.0</version>
<version>7.9.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.8.0</version>
<version>7.9.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.8.0</version>
<version>7.9.0</version>
</parent>

<artifactId>telegrambots-meta</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package org.telegram.telegrambots.meta.api.methods.groupadministration;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import lombok.experimental.Tolerate;
import lombok.extern.jackson.Jacksonized;
import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ChatInviteLink;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;

/**
* @author Ruben Bermudez
* @version 7.9
*
* Use this method to create a subscription invite link for a channel chat.
* Returns the new invite link as a ChatInviteLink object.
*
* @apiNote The bot must have can_invite_users administrator rights.
* @apiNote The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@AllArgsConstructor
@RequiredArgsConstructor
@SuperBuilder
@Jacksonized
@JsonIgnoreProperties(ignoreUnknown = true)
public class CreateChatSubscriptionInviteLink extends BotApiMethod<ChatInviteLink> {
public static final String PATH = "createChatSubscriptionInviteLink";

private static final String CHAT_ID_FIELD = "chat_id";
private static final String SUBSCRIPTION_PERIOD_FIELD = "subscription_period";
private static final String SUBSCRIPTION_PRICE_FIELD = "subscription_price";
private static final String NAME_FIELD = "name";

/**
* Unique identifier for the target channel chat or username of the target channel (in the format @channelusername)
*/
@JsonProperty(CHAT_ID_FIELD)
@NonNull
private String chatId;
/**
* The number of seconds the subscription will be active for before the next payment.
* Currently, it must always be 2592000 (30 days).
*/
@JsonProperty(SUBSCRIPTION_PERIOD_FIELD)
@NonNull
@Builder.Default
private Integer subscriptionPeriod = 2592000;
/**
* 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
*/
@JsonProperty(SUBSCRIPTION_PRICE_FIELD)
@NonNull
private Integer subscriptionPrice;
/**
* Optional
* Invite link name; 0-32 characters
*/
@JsonProperty(NAME_FIELD)
private String name;

@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}

@Override
public String getMethod() {
return PATH;
}

@Override
public ChatInviteLink deserializeResponse(String answer) throws TelegramApiRequestException {
return deserializeResponse(answer, ChatInviteLink.class);
}

@Override
public void validate() throws TelegramApiValidationException {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (name != null && name.length() > 32) {
throw new TelegramApiValidationException("Name must be between 0 and 32 characters", this);
}
if (subscriptionPeriod != 2592000) {
throw new TelegramApiValidationException("SubscriptionPeriod must be 2592000", this);
}
if (subscriptionPrice < 1 || subscriptionPrice > 2500) {
throw new TelegramApiValidationException("SubscriptionPrice must be between 1 and 2500", this);
}
}

public static abstract class CreateChatSubscriptionInviteLinkBuilder<C extends CreateChatSubscriptionInviteLink, B extends CreateChatSubscriptionInviteLinkBuilder<C, B>> extends BotApiMethodBuilder<ChatInviteLink, C, B> {
@Tolerate
public CreateChatSubscriptionInviteLinkBuilder<C, B> chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package org.telegram.telegrambots.meta.api.methods.groupadministration;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import lombok.experimental.Tolerate;
import lombok.extern.jackson.Jacksonized;
import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ChatInviteLink;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;

/**
* @author Ruben Bermudez
* @version 7.9
*
* Use this method to edit a subscription invite link created by the bot.
* Returns the edited invite link as a ChatInviteLink object.
*
* @apiNote The bot must have can_invite_users administrator rights.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@AllArgsConstructor
@RequiredArgsConstructor
@SuperBuilder
@Jacksonized
@JsonIgnoreProperties(ignoreUnknown = true)
public class EditChatSubscriptionInviteLink extends BotApiMethod<ChatInviteLink> {
public static final String PATH = "editChatSubscriptionInviteLink";

private static final String CHAT_ID_FIELD = "chat_id";
private static final String INVITE_LINK_FIELD = "invite_link";
private static final String NAME_FIELD = "name";

/**
* Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
@JsonProperty(CHAT_ID_FIELD)
@NonNull
private String chatId;
/**
* The number of seconds the subscription will be active for before the next payment.
* Currently, it must always be 2592000 (30 days).
*/
@JsonProperty(INVITE_LINK_FIELD)
@NonNull
private String inviteLink;
/**
* Optional
* Invite link name; 0-32 characters
*/
@JsonProperty(NAME_FIELD)
private String name;

@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}

@Override
public String getMethod() {
return PATH;
}

@Override
public ChatInviteLink deserializeResponse(String answer) throws TelegramApiRequestException {
return deserializeResponse(answer, ChatInviteLink.class);
}

@Override
public void validate() throws TelegramApiValidationException {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (name != null && name.length() > 32) {
throw new TelegramApiValidationException("Name must be between 0 and 32 characters", this);
}
if (inviteLink.isEmpty()) {
throw new TelegramApiValidationException("InviteLink must not be empty", this);
}
}

public static abstract class EditChatSubscriptionInviteLinkBuilder<C extends EditChatSubscriptionInviteLink, B extends EditChatSubscriptionInviteLinkBuilder<C, B>> extends BotApiMethodBuilder<ChatInviteLink, C, B> {
@Tolerate
public EditChatSubscriptionInviteLinkBuilder<C, B> chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
* In albums, bots must react to the first message.
*
* Returns True on success.
*
* @apiNote Bots can't use paid reactions
*/
@SuppressWarnings("unused")
@EqualsAndHashCode(callSuper = false)
Expand Down Expand Up @@ -64,6 +66,7 @@ public class SetMessageReaction extends BotApiMethodBoolean {
* New list of reaction types to set on the message.
* Currently, as non-premium users, bots can set up to one reaction per message.
* A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators.
* @apiNote Paid reactions can't be used by bots.
*/
@JsonProperty(REACTION_FIELD)
private List<ReactionType> reactionTypes;
Expand All @@ -74,7 +77,6 @@ public class SetMessageReaction extends BotApiMethodBoolean {
@JsonProperty(IS_BIG_FIELD)
private Boolean isBig;


@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
Expand All @@ -92,6 +94,9 @@ public void validate() throws TelegramApiValidationException {
}
if (reactionTypes != null) {
for (ReactionType reactionType : reactionTypes) {
if (ReactionType.PAID_TYPE.equals(reactionType.getType())) {
throw new TelegramApiValidationException("ReactionType can't be paid", this);
}
reactionType.validate();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ public class SendPaidMedia extends PartialBotApiMethod<ArrayList<Message>> {
public static final String PROTECT_CONTENT_FIELD = "protect_content";
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";

/**
* Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* Unique identifier for the target chat or username of the target channel (in the format @channelusername).
* If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance.
* Otherwise, they will be credited to the bot's balance.
*/
@NonNull
private String chatId;
Expand Down Expand Up @@ -111,6 +114,11 @@ public class SendPaidMedia extends PartialBotApiMethod<ArrayList<Message>> {
* instructions to remove a reply keyboard or to force a reply from the user
*/
private ReplyKeyboard replyMarkup;
/**
* Optional
* Unique identifier of the business connection on behalf of which the message will be sent
*/
private String businessConnectionId;

@Tolerate
public void setChatId(@NonNull Long chatId) {
Expand Down
Loading

0 comments on commit 5fc7d88

Please sign in to comment.