Skip to content

Commit 5fc7d88

Browse files
committed
Api Version 7.9
1 parent d7f4a74 commit 5fc7d88

File tree

21 files changed

+420
-118
lines changed

21 files changed

+420
-118
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<groupId>org.telegram</groupId>
88
<artifactId>Bots</artifactId>
99
<packaging>pom</packaging>
10-
<version>7.8.0</version>
10+
<version>7.9.0</version>
1111

1212
<modules>
1313
<module>telegrambots-meta</module>

telegrambots-abilities/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.telegram</groupId>
99
<artifactId>Bots</artifactId>
10-
<version>7.8.0</version>
10+
<version>7.9.0</version>
1111
</parent>
1212

1313
<artifactId>telegrambots-abilities</artifactId>
@@ -104,12 +104,12 @@
104104
<dependency>
105105
<groupId>org.telegram</groupId>
106106
<artifactId>telegrambots-webhook</artifactId>
107-
<version>7.8.0</version>
107+
<version>7.9.0</version>
108108
</dependency>
109109
<dependency>
110110
<groupId>org.telegram</groupId>
111111
<artifactId>telegrambots-longpolling</artifactId>
112-
<version>7.8.0</version>
112+
<version>7.9.0</version>
113113
</dependency>
114114

115115
<dependency>

telegrambots-client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.telegram</groupId>
99
<artifactId>Bots</artifactId>
10-
<version>7.8.0</version>
10+
<version>7.9.0</version>
1111
</parent>
1212

1313
<name>Telegram Bots Client</name>

telegrambots-client/src/main/java/org/telegram/telegrambots/client/okhttp/OkHttpTelegramClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ public CompletableFuture<List<Message>> executeAsync(SendPaidMedia sendPaidMedia
261261
.addPart(SendPaidMedia.SHOW_CAPTION_ABOVE_MEDIA_FIELD, sendPaidMedia.getShowCaptionAboveMedia())
262262
.addPart(SendPaidMedia.DISABLE_NOTIFICATION_FIELD, sendPaidMedia.getDisableNotification())
263263
.addPart(SendPaidMedia.PROTECT_CONTENT_FIELD, sendPaidMedia.getProtectContent())
264+
.addPart(SendPaidMedia.BUSINESS_CONNECTION_ID_FIELD, sendPaidMedia.getBusinessConnectionId())
264265
.addJsonPart(SendPaidMedia.CAPTION_ENTITIES_FIELD, sendPaidMedia.getCaptionEntities())
265266
.addJsonPart(SendPaidMedia.REPLY_MARKUP_FIELD, sendPaidMedia.getReplyMarkup())
266267
.addJsonPart(SendPaidMedia.REPLY_PARAMETERS_FIELD, sendPaidMedia.getReplyParameters());

telegrambots-extensions/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ Just import add the library to your project with one of these options:
1616
<dependency>
1717
<groupId>org.telegram</groupId>
1818
<artifactId>telegrambots-extensions</artifactId>
19-
<version>7.8.0</version>
19+
<version>7.9.0</version>
2020
</dependency>
2121
```
2222

2323
2. Using Gradle:
2424

2525
```gradle
26-
implementation 'org.telegram:telegrambots-extensions:7.8.0'
26+
implementation 'org.telegram:telegrambots-extensions:7.9.0'
2727
```

telegrambots-extensions/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.telegram</groupId>
99
<artifactId>Bots</artifactId>
10-
<version>7.8.0</version>
10+
<version>7.9.0</version>
1111
</parent>
1212

1313
<artifactId>telegrambots-extensions</artifactId>
@@ -89,12 +89,12 @@
8989
<dependency>
9090
<groupId>org.telegram</groupId>
9191
<artifactId>telegrambots-webhook</artifactId>
92-
<version>7.8.0</version>
92+
<version>7.9.0</version>
9393
</dependency>
9494
<dependency>
9595
<groupId>org.telegram</groupId>
9696
<artifactId>telegrambots-longpolling</artifactId>
97-
<version>7.8.0</version>
97+
<version>7.9.0</version>
9898
</dependency>
9999

100100
<dependency>

telegrambots-longpolling/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>org.telegram</groupId>
88
<artifactId>Bots</artifactId>
9-
<version>7.8.0</version>
9+
<version>7.9.0</version>
1010
</parent>
1111

1212
<artifactId>telegrambots-longpolling</artifactId>

telegrambots-meta/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.telegram</groupId>
99
<artifactId>Bots</artifactId>
10-
<version>7.8.0</version>
10+
<version>7.9.0</version>
1111
</parent>
1212

1313
<artifactId>telegrambots-meta</artifactId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package org.telegram.telegrambots.meta.api.methods.groupadministration;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import lombok.AllArgsConstructor;
6+
import lombok.Builder;
7+
import lombok.EqualsAndHashCode;
8+
import lombok.Getter;
9+
import lombok.NonNull;
10+
import lombok.RequiredArgsConstructor;
11+
import lombok.Setter;
12+
import lombok.ToString;
13+
import lombok.experimental.SuperBuilder;
14+
import lombok.experimental.Tolerate;
15+
import lombok.extern.jackson.Jacksonized;
16+
import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethod;
17+
import org.telegram.telegrambots.meta.api.objects.ChatInviteLink;
18+
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
19+
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
20+
21+
/**
22+
* @author Ruben Bermudez
23+
* @version 7.9
24+
*
25+
* Use this method to create a subscription invite link for a channel chat.
26+
* Returns the new invite link as a ChatInviteLink object.
27+
*
28+
* @apiNote The bot must have can_invite_users administrator rights.
29+
* @apiNote The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink.
30+
*/
31+
@EqualsAndHashCode(callSuper = false)
32+
@Getter
33+
@Setter
34+
@ToString
35+
@AllArgsConstructor
36+
@RequiredArgsConstructor
37+
@SuperBuilder
38+
@Jacksonized
39+
@JsonIgnoreProperties(ignoreUnknown = true)
40+
public class CreateChatSubscriptionInviteLink extends BotApiMethod<ChatInviteLink> {
41+
public static final String PATH = "createChatSubscriptionInviteLink";
42+
43+
private static final String CHAT_ID_FIELD = "chat_id";
44+
private static final String SUBSCRIPTION_PERIOD_FIELD = "subscription_period";
45+
private static final String SUBSCRIPTION_PRICE_FIELD = "subscription_price";
46+
private static final String NAME_FIELD = "name";
47+
48+
/**
49+
* Unique identifier for the target channel chat or username of the target channel (in the format @channelusername)
50+
*/
51+
@JsonProperty(CHAT_ID_FIELD)
52+
@NonNull
53+
private String chatId;
54+
/**
55+
* The number of seconds the subscription will be active for before the next payment.
56+
* Currently, it must always be 2592000 (30 days).
57+
*/
58+
@JsonProperty(SUBSCRIPTION_PERIOD_FIELD)
59+
@NonNull
60+
@Builder.Default
61+
private Integer subscriptionPeriod = 2592000;
62+
/**
63+
* 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
64+
*/
65+
@JsonProperty(SUBSCRIPTION_PRICE_FIELD)
66+
@NonNull
67+
private Integer subscriptionPrice;
68+
/**
69+
* Optional
70+
* Invite link name; 0-32 characters
71+
*/
72+
@JsonProperty(NAME_FIELD)
73+
private String name;
74+
75+
@Tolerate
76+
public void setChatId(@NonNull Long chatId) {
77+
this.chatId = chatId.toString();
78+
}
79+
80+
@Override
81+
public String getMethod() {
82+
return PATH;
83+
}
84+
85+
@Override
86+
public ChatInviteLink deserializeResponse(String answer) throws TelegramApiRequestException {
87+
return deserializeResponse(answer, ChatInviteLink.class);
88+
}
89+
90+
@Override
91+
public void validate() throws TelegramApiValidationException {
92+
if (chatId.isEmpty()) {
93+
throw new TelegramApiValidationException("ChatId can't be empty", this);
94+
}
95+
if (name != null && name.length() > 32) {
96+
throw new TelegramApiValidationException("Name must be between 0 and 32 characters", this);
97+
}
98+
if (subscriptionPeriod != 2592000) {
99+
throw new TelegramApiValidationException("SubscriptionPeriod must be 2592000", this);
100+
}
101+
if (subscriptionPrice < 1 || subscriptionPrice > 2500) {
102+
throw new TelegramApiValidationException("SubscriptionPrice must be between 1 and 2500", this);
103+
}
104+
}
105+
106+
public static abstract class CreateChatSubscriptionInviteLinkBuilder<C extends CreateChatSubscriptionInviteLink, B extends CreateChatSubscriptionInviteLinkBuilder<C, B>> extends BotApiMethodBuilder<ChatInviteLink, C, B> {
107+
@Tolerate
108+
public CreateChatSubscriptionInviteLinkBuilder<C, B> chatId(@NonNull Long chatId) {
109+
this.chatId = chatId.toString();
110+
return this;
111+
}
112+
}
113+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package org.telegram.telegrambots.meta.api.methods.groupadministration;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import lombok.AllArgsConstructor;
6+
import lombok.EqualsAndHashCode;
7+
import lombok.Getter;
8+
import lombok.NonNull;
9+
import lombok.RequiredArgsConstructor;
10+
import lombok.Setter;
11+
import lombok.ToString;
12+
import lombok.experimental.SuperBuilder;
13+
import lombok.experimental.Tolerate;
14+
import lombok.extern.jackson.Jacksonized;
15+
import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethod;
16+
import org.telegram.telegrambots.meta.api.objects.ChatInviteLink;
17+
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
18+
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
19+
20+
/**
21+
* @author Ruben Bermudez
22+
* @version 7.9
23+
*
24+
* Use this method to edit a subscription invite link created by the bot.
25+
* Returns the edited invite link as a ChatInviteLink object.
26+
*
27+
* @apiNote The bot must have can_invite_users administrator rights.
28+
*/
29+
@EqualsAndHashCode(callSuper = false)
30+
@Getter
31+
@Setter
32+
@ToString
33+
@AllArgsConstructor
34+
@RequiredArgsConstructor
35+
@SuperBuilder
36+
@Jacksonized
37+
@JsonIgnoreProperties(ignoreUnknown = true)
38+
public class EditChatSubscriptionInviteLink extends BotApiMethod<ChatInviteLink> {
39+
public static final String PATH = "editChatSubscriptionInviteLink";
40+
41+
private static final String CHAT_ID_FIELD = "chat_id";
42+
private static final String INVITE_LINK_FIELD = "invite_link";
43+
private static final String NAME_FIELD = "name";
44+
45+
/**
46+
* Unique identifier for the target chat or username of the target channel (in the format @channelusername)
47+
*/
48+
@JsonProperty(CHAT_ID_FIELD)
49+
@NonNull
50+
private String chatId;
51+
/**
52+
* The number of seconds the subscription will be active for before the next payment.
53+
* Currently, it must always be 2592000 (30 days).
54+
*/
55+
@JsonProperty(INVITE_LINK_FIELD)
56+
@NonNull
57+
private String inviteLink;
58+
/**
59+
* Optional
60+
* Invite link name; 0-32 characters
61+
*/
62+
@JsonProperty(NAME_FIELD)
63+
private String name;
64+
65+
@Tolerate
66+
public void setChatId(@NonNull Long chatId) {
67+
this.chatId = chatId.toString();
68+
}
69+
70+
@Override
71+
public String getMethod() {
72+
return PATH;
73+
}
74+
75+
@Override
76+
public ChatInviteLink deserializeResponse(String answer) throws TelegramApiRequestException {
77+
return deserializeResponse(answer, ChatInviteLink.class);
78+
}
79+
80+
@Override
81+
public void validate() throws TelegramApiValidationException {
82+
if (chatId.isEmpty()) {
83+
throw new TelegramApiValidationException("ChatId can't be empty", this);
84+
}
85+
if (name != null && name.length() > 32) {
86+
throw new TelegramApiValidationException("Name must be between 0 and 32 characters", this);
87+
}
88+
if (inviteLink.isEmpty()) {
89+
throw new TelegramApiValidationException("InviteLink must not be empty", this);
90+
}
91+
}
92+
93+
public static abstract class EditChatSubscriptionInviteLinkBuilder<C extends EditChatSubscriptionInviteLink, B extends EditChatSubscriptionInviteLinkBuilder<C, B>> extends BotApiMethodBuilder<ChatInviteLink, C, B> {
94+
@Tolerate
95+
public EditChatSubscriptionInviteLinkBuilder<C, B> chatId(@NonNull Long chatId) {
96+
this.chatId = chatId.toString();
97+
return this;
98+
}
99+
}
100+
}

0 commit comments

Comments
 (0)