Skip to content

Commit 09f7a54

Browse files
committed
Added the ability to change thumbnails of sticker sets created by the bot using the method setStickerSetThumb
1 parent 4e6ca81 commit 09f7a54

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.pengrad.telegrambot.request;
2+
3+
import com.pengrad.telegrambot.response.BaseResponse;
4+
5+
/**
6+
* Stas Parshin
7+
* 31 March 2020
8+
*/
9+
public class SetStickerSetThumb extends AbstractUploadRequest<AddStickerToSet, BaseResponse> {
10+
11+
public SetStickerSetThumb(String name, Integer userId, Object thumb) {
12+
super(BaseResponse.class, "thumb", thumb);
13+
add("name", name);
14+
add("user_id", userId);
15+
}
16+
17+
public SetStickerSetThumb(String name, Integer userId) {
18+
super(BaseResponse.class, "name", name);
19+
add("user_id", userId);
20+
}
21+
}

library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
import com.pengrad.telegrambot.request.SetGameScore;
157157
import com.pengrad.telegrambot.request.SetMyCommands;
158158
import com.pengrad.telegrambot.request.SetStickerPositionInSet;
159+
import com.pengrad.telegrambot.request.SetStickerSetThumb;
159160
import com.pengrad.telegrambot.request.SetWebhook;
160161
import com.pengrad.telegrambot.request.StopMessageLiveLocation;
161162
import com.pengrad.telegrambot.request.StopPoll;
@@ -296,6 +297,7 @@ public static TelegramBot createTestBot() {
296297
static String gifFileId = "CgADAgADfQADgNqgSTt9SzatJhc3FgQ";
297298
static String withSpaceFileId = "BAADAgADZwADkg-4SQI5WM0SPNHrAg";
298299
static String stickerSet = "testset_by_pengrad_test_bot";
300+
static String stickerSetAnim = "testset_anim_by_pengrad_test_bot";
299301
static String imageUrl = "https://telegram.org/img/t_logo.png";
300302
static File thumbFile = resourcePath.resolve("thumb.jpg").toFile();
301303
static byte[] thumbBytes;
@@ -1389,6 +1391,17 @@ public void deleteStickerFromSet() {
13891391
}
13901392
}
13911393

1394+
@Test
1395+
public void setStickerSetThumb() {
1396+
String thumbFile = "CAACAgIAAxkBAAJ0ll6DO4bNCynpfZmS6g-YcGY2zrP5AAIBAAPANk8TGC5zMKs_LVEYBA";
1397+
BaseResponse response = bot.execute(new SetStickerSetThumb(stickerSetAnim, chatId, thumbFile));
1398+
assertTrue(response.isOk());
1399+
1400+
// clear thumb by not sending it
1401+
response = bot.execute(new SetStickerSetThumb(stickerSetAnim, chatId));
1402+
assertTrue(response.isOk());
1403+
}
1404+
13921405
@Test
13931406
public void editMessageLiveLocation() {
13941407
BaseResponse response = bot.execute(new EditMessageLiveLocation(chatId, 10009, 21, 105)

0 commit comments

Comments
 (0)