Skip to content

Commit 85eee5a

Browse files
authored
Merge pull request #295 from mircoianese/api_6.2
BOT Api v6.2
2 parents f38e0f1 + 39d9fc8 commit 85eee5a

File tree

7 files changed

+109
-6
lines changed

7 files changed

+109
-6
lines changed

library/src/main/java/com/pengrad/telegrambot/model/Chat.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public enum Type {
3232
private ChatPhoto photo;
3333
private String bio;
3434
private Boolean has_private_forwards;
35+
private Boolean has_restricted_voice_and_video_messages;
3536
private Boolean join_to_send_messages;
3637
private Boolean join_by_request;
3738
private String description;
@@ -82,6 +83,10 @@ public Boolean hasPrivateForwards() {
8283
return has_private_forwards != null && has_private_forwards;
8384
}
8485

86+
public Boolean hasRestrictedVoiceAndVideoMessages() {
87+
return has_restricted_voice_and_video_messages != null && has_restricted_voice_and_video_messages;
88+
}
89+
8590
public Boolean joinToSendMessages() {
8691
return join_to_send_messages != null && join_to_send_messages;
8792
}
@@ -148,6 +153,7 @@ public boolean equals(Object o) {
148153
Objects.equals(photo, chat.photo) &&
149154
Objects.equals(bio, chat.bio) &&
150155
Objects.equals(has_private_forwards, chat.has_private_forwards) &&
156+
Objects.equals(has_restricted_voice_and_video_messages, chat.has_restricted_voice_and_video_messages) &&
151157
Objects.equals(join_to_send_messages, chat.join_to_send_messages) &&
152158
Objects.equals(join_by_request, chat.join_by_request) &&
153159
Objects.equals(description, chat.description) &&
@@ -180,6 +186,7 @@ public String toString() {
180186
", photo=" + photo +
181187
", bio='" + bio + '\'' +
182188
", has_private_forwards=" + has_private_forwards +
189+
", has_restricted_voice_and_video_messages=" + has_restricted_voice_and_video_messages +
183190
", join_to_send_messages=" + join_to_send_messages +
184191
", join_by_request=" + join_by_request +
185192
", description='" + description + '\'' +

library/src/main/java/com/pengrad/telegrambot/model/MessageEntity.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class MessageEntity implements Serializable {
1212

1313
public enum Type {
1414
mention, hashtag, cashtag, bot_command, url, email, phone_number, bold, italic, code, pre, text_link,
15-
text_mention, underline, strikethrough, spoiler
15+
text_mention, underline, strikethrough, spoiler, custom_emoji
1616
}
1717

1818
private Type type;
@@ -21,6 +21,7 @@ public enum Type {
2121
private String url;
2222
private User user;
2323
private String language;
24+
private String custom_emoji_id;
2425

2526
private MessageEntity() {
2627
}
@@ -55,6 +56,10 @@ public String language() {
5556
return language;
5657
}
5758

59+
public String customEmojiId() {
60+
return custom_emoji_id;
61+
}
62+
5863
public MessageEntity url(String url) {
5964
this.url = url;
6065
return this;
@@ -70,6 +75,11 @@ public MessageEntity language(String language) {
7075
return this;
7176
}
7277

78+
public MessageEntity customEmojiId(String custom_emoji_id) {
79+
this.custom_emoji_id = custom_emoji_id;
80+
return this;
81+
}
82+
7383
@Override
7484
public boolean equals(Object o) {
7585
if (this == o) return true;
@@ -80,12 +90,13 @@ public boolean equals(Object o) {
8090
Objects.equals(length, that.length) &&
8191
Objects.equals(url, that.url) &&
8292
Objects.equals(user, that.user) &&
83-
Objects.equals(language, that.language);
93+
Objects.equals(language, that.language) &&
94+
Objects.equals(custom_emoji_id, that.custom_emoji_id);
8495
}
8596

8697
@Override
8798
public int hashCode() {
88-
return Objects.hash(type, offset, length, url, user, language);
99+
return Objects.hash(type, offset, length, url, user, language, custom_emoji_id);
89100
}
90101

91102
@Override
@@ -97,6 +108,7 @@ public String toString() {
97108
", url='" + url + '\'' +
98109
", user=" + user +
99110
", language='" + language + '\'' +
111+
", custom_emoji_id='" + custom_emoji_id + '\'' +
100112
'}';
101113
}
102114
}

library/src/main/java/com/pengrad/telegrambot/model/Sticker.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@
88
* 8/5/15.
99
*/
1010
public class Sticker implements Serializable {
11+
12+
public enum Type {
13+
regular, mask, custom_emoji
14+
}
15+
1116
private final static long serialVersionUID = 0L;
1217

1318
private String file_id;
1419
private String file_unique_id;
20+
private Type type;
1521
private Integer width;
1622
private Integer height;
1723
private Boolean is_animated;
@@ -21,6 +27,7 @@ public class Sticker implements Serializable {
2127
private String set_name;
2228
private File premium_animation;
2329
private MaskPosition mask_position;
30+
private String custom_emoji_id;
2431
private Long file_size;
2532

2633
public String fileId() {
@@ -31,6 +38,10 @@ public String fileUniqueId() {
3138
return file_unique_id;
3239
}
3340

41+
public Type type() {
42+
return type;
43+
}
44+
3445
public Integer width() {
3546
return width;
3647
}
@@ -67,6 +78,10 @@ public MaskPosition maskPosition() {
6778
return mask_position;
6879
}
6980

81+
public String customEmojiId() {
82+
return custom_emoji_id;
83+
}
84+
7085
public Long fileSize() {
7186
return file_size;
7287
}
@@ -78,6 +93,7 @@ public boolean equals(Object o) {
7893
Sticker sticker = (Sticker) o;
7994
return Objects.equals(file_id, sticker.file_id) &&
8095
Objects.equals(file_unique_id, sticker.file_unique_id) &&
96+
Objects.equals(type, sticker.type) &&
8197
Objects.equals(width, sticker.width) &&
8298
Objects.equals(height, sticker.height) &&
8399
Objects.equals(is_animated, sticker.is_animated) &&
@@ -87,6 +103,7 @@ public boolean equals(Object o) {
87103
Objects.equals(set_name, sticker.set_name) &&
88104
Objects.equals(premium_animation, sticker.premium_animation) &&
89105
Objects.equals(mask_position, sticker.mask_position) &&
106+
Objects.equals(custom_emoji_id, sticker.custom_emoji_id) &&
90107
Objects.equals(file_size, sticker.file_size);
91108
}
92109

@@ -100,6 +117,7 @@ public String toString() {
100117
return "Sticker{" +
101118
"file_id='" + file_id + '\'' +
102119
", file_unique_id='" + file_unique_id + '\'' +
120+
", type=" + type +
103121
", width=" + width +
104122
", height=" + height +
105123
", is_animated=" + is_animated +
@@ -109,6 +127,7 @@ public String toString() {
109127
", set_name='" + set_name + '\'' +
110128
", premium_animation=" + premium_animation +
111129
", mask_position=" + mask_position +
130+
", custom_emoji_id=" + custom_emoji_id +
112131
", file_size=" + file_size +
113132
'}';
114133
}

library/src/main/java/com/pengrad/telegrambot/model/StickerSet.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import java.util.Arrays;
55
import java.util.Objects;
66

7+
import com.pengrad.telegrambot.model.Sticker.Type;
8+
79
/**
810
* Stas Parshin
911
* 23 July 2017
@@ -13,6 +15,7 @@ public class StickerSet implements Serializable {
1315

1416
private String name;
1517
private String title;
18+
private Type sticker_type;
1619
private Boolean is_animated;
1720
private Boolean is_video;
1821
private Boolean contains_masks;
@@ -27,10 +30,18 @@ public String title() {
2730
return title;
2831
}
2932

33+
public Type stickerType() {
34+
return sticker_type;
35+
}
36+
3037
public Boolean isAnimated() {
3138
return is_animated;
3239
}
3340

41+
/**
42+
* @deprecated Use type() and check if it equals to Type.mask
43+
*/
44+
@Deprecated
3445
public Boolean containsMasks() {
3546
return contains_masks;
3647
}
@@ -54,16 +65,16 @@ public boolean equals(Object o) {
5465
StickerSet that = (StickerSet) o;
5566
return Objects.equals(name, that.name) &&
5667
Objects.equals(title, that.title) &&
68+
Objects.equals(sticker_type, that.sticker_type) &&
5769
Objects.equals(is_animated, that.is_animated) &&
5870
Objects.equals(is_video, that.is_video) &&
59-
Objects.equals(contains_masks, that.contains_masks) &&
6071
Arrays.equals(stickers, that.stickers) &&
6172
Objects.equals(thumb, that.thumb);
6273
}
6374

6475
@Override
6576
public int hashCode() {
66-
int result = Objects.hash(name, title, is_animated, is_video, contains_masks, thumb);
77+
int result = Objects.hash(name, title, sticker_type, is_animated, is_video, thumb);
6778
result = 31 * result + Arrays.hashCode(stickers);
6879
return result;
6980
}
@@ -73,9 +84,9 @@ public String toString() {
7384
return "StickerSet{" +
7485
"name='" + name + '\'' +
7586
", title='" + title + '\'' +
87+
", sticker_type='" + sticker_type + '\'' +
7688
", is_animated=" + is_animated +
7789
", is_video=" + is_video +
78-
", contains_masks=" + contains_masks +
7990
", stickers=" + Arrays.toString(stickers) +
8091
", thumb=" + thumb +
8192
'}';

library/src/main/java/com/pengrad/telegrambot/request/CreateNewStickerSet.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.pengrad.telegrambot.request;
22

33
import com.pengrad.telegrambot.model.MaskPosition;
4+
import com.pengrad.telegrambot.model.Sticker.Type;
45
import com.pengrad.telegrambot.response.BaseResponse;
56

67
/**
@@ -37,11 +38,24 @@ private CreateNewStickerSet(Long userId, String name, String title, String emoji
3738
add("emojis", emojis);
3839
}
3940

41+
/**
42+
* @deprecated Use stickerType(Type.mask) instead
43+
*/
44+
@Deprecated
4045
public CreateNewStickerSet containsMasks(boolean containsMasks) {
4146
return add("contains_masks", containsMasks);
4247
}
4348

4449
public CreateNewStickerSet maskPosition(MaskPosition maskPosition) {
4550
return add("mask_position", maskPosition).containsMasks(true);
4651
}
52+
53+
/**
54+
* Type of stickers in the set.
55+
* @param stickerType pass “regular” or “mask”. "custom_emoji" is defaulted to "regular".
56+
* @return a CreateNewStickerSet object
57+
*/
58+
public CreateNewStickerSet stickerType(Type stickerType) {
59+
return add("sticker_type", stickerType.name());
60+
}
4761
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.pengrad.telegrambot.request;
2+
3+
import com.pengrad.telegrambot.response.GetCustomEmojiStickersResponse;
4+
5+
/**
6+
* Mirco Ianese
7+
* 16 Aug 2022
8+
*/
9+
public class GetCustomEmojiStickers extends BaseRequest<GetCustomEmojiStickers, GetCustomEmojiStickersResponse> {
10+
11+
public GetCustomEmojiStickers(String... custom_emoji_ids) {
12+
super(GetCustomEmojiStickersResponse.class);
13+
add("custom_emoji_ids", custom_emoji_ids);
14+
}
15+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.pengrad.telegrambot.response;
2+
3+
import java.util.Arrays;
4+
5+
import com.pengrad.telegrambot.model.Sticker;
6+
7+
/**
8+
* Mirco Ianese
9+
* 16 Aug 2022
10+
*/
11+
public class GetCustomEmojiStickersResponse extends BaseResponse {
12+
13+
private Sticker[] result;
14+
15+
public Sticker[] result() {
16+
return result;
17+
}
18+
19+
@Override
20+
public String toString() {
21+
return "GetCustomEmojiStickersResponse{" +
22+
"result=" + Arrays.toString(result) +
23+
'}';
24+
}
25+
}

0 commit comments

Comments
 (0)