Skip to content

Commit b69ad30

Browse files
committed
Configure new answer to show currently supported formats
1 parent e2e12d9 commit b69ad30

4 files changed

Lines changed: 88 additions & 2 deletions

File tree

src/main/java/com/github/stickerifier/stickerify/telegram/Answer.java

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public enum Answer {
1313
- no file, if you sent a media already suiting Telegram's requirements
1414
- an error message, if you sent either an unsupported or a corrupted file
1515
- an informative message for any message without a file
16+
- the list of supported files, using the /supported command
1617
1718
Once the file is ready, head to [Stickers](https://t.me/Stickers) to create a new sticker.
1819
"""),
@@ -28,14 +29,14 @@ public enum Answer {
2829
The file can't be converted because Telegram bots can't handle files larger than 20 MB at the moment: please send a smaller one.
2930
"""),
3031
ABOUT("""
31-
This bot is open source, check it out on [Github](https://github.com/Stickerifier/Stickerify).
32+
This bot is open source, check it out on [GitHub](https://github.com/Stickerifier/Stickerify).
3233
3334
Looking for sticker packs? Try [MeminiCustom](https://t.me/addstickers/MeminiCustom) and [VideoMemini](https://t.me/addstickers/VideoMemini)!
3435
"""),
3536
ERROR("""
3637
The file conversion was unsuccessful: only images, gifs, standard and video stickers are supported.
3738
38-
If you think it should have worked, please report the issue on [Github](https://github.com/Stickerifier/Stickerify/issues/new/choose).
39+
If you think it should have worked, please report the issue on [GitHub](https://github.com/Stickerifier/Stickerify/issues/new/choose).
3940
"""),
4041
PRIVACY_POLICY("""
4142
You can view our privacy policy by visiting [this link](https://stickerifier.github.io/Stickerify/PRIVACY_POLICY.html).
@@ -44,6 +45,53 @@ public enum Answer {
4445
"""),
4546
PROCESSING("""
4647
<tg-thinking>Processing file...</tg-thinking>
48+
"""),
49+
SUPPORTED_FORMATS("""
50+
### Supported formats
51+
52+
<details><summary>Images</summary>
53+
54+
| Format | Support status |
55+
|:------------|:--------------:|
56+
| png | ✔ |
57+
| jpg / jpeg | ✔ |
58+
| static webp | ✔ |
59+
| tiff | ✔ |
60+
| ico | ✔ |
61+
| svg | ✔ |
62+
| psd | ✔ |
63+
64+
</details>
65+
66+
<details><summary>Videos</summary>
67+
68+
| Format | Support status |
69+
|:--------------|:--------------:|
70+
| gif | ✔ |
71+
| mov | ✔ |
72+
| avi | ✔ |
73+
| mp4 | ✔ |
74+
| webm | ✔ |
75+
| m4v | ✔ |
76+
| mkv | ✔ |
77+
| live photos | ✔ |
78+
| animated webp | ✖ |
79+
80+
</details>
81+
82+
<details><summary>Stickers</summary>
83+
84+
| Format | Support status |
85+
|:---------------------------------------------------------------------------|:--------------:|
86+
| static, for instance [MeminiCustom](https://t.me/addstickers/MeminiCustom) | ✔ |
87+
| video, for instance [VideoMemini](https://t.me/addstickers/VideoMemini) | ✔ |
88+
| animated, for instance [HotCherry](https://t.me/addstickers/HotCherry) | ✔ |
89+
90+
</details>
91+
92+
---
93+
94+
If you want to see a format added, please let us know by creating an issue on [GitHub](https://github.com/Stickerifier/Stickerify/issues/new).
4795
""");
4896

4997
private final String text;

src/main/java/com/github/stickerifier/stickerify/telegram/model/TelegramRequest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static com.github.stickerifier.stickerify.telegram.Answer.ABOUT;
44
import static com.github.stickerifier.stickerify.telegram.Answer.HELP;
55
import static com.github.stickerifier.stickerify.telegram.Answer.PRIVACY_POLICY;
6+
import static com.github.stickerifier.stickerify.telegram.Answer.SUPPORTED_FORMATS;
67
import static java.util.Comparator.comparing;
78

89
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -31,6 +32,7 @@ public record TelegramRequest(Message message) {
3132
private static final String START_COMMAND = "/start";
3233
private static final String HELP_COMMAND = "/help";
3334
private static final String PRIVACY_COMMAND = "/privacy";
35+
private static final String SUPPORTED_COMMAND = "/supported";
3436

3537
public @Nullable TelegramFile getFile() {
3638
return getMessageMedia()
@@ -82,6 +84,7 @@ public Answer getAnswerMessage() {
8284
return switch (message.text()) {
8385
case HELP_COMMAND, START_COMMAND -> HELP;
8486
case PRIVACY_COMMAND -> PRIVACY_POLICY;
87+
case SUPPORTED_COMMAND -> SUPPORTED_FORMATS;
8588
case null, default -> ABOUT;
8689
};
8790
}

src/test/java/com/github/stickerifier/stickerify/bot/MockResponses.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,27 @@ public final class MockResponses {
7676
}
7777
""").build();
7878

79+
static final MockResponse SUPPORTED_MESSAGE = new MockResponse.Builder().body("""
80+
{
81+
ok: true,
82+
result: [
83+
{
84+
update_id: 1,
85+
message: {
86+
message_id: 1,
87+
from: {
88+
id: 123456
89+
},
90+
chat: {
91+
id: 1
92+
},
93+
text: "/supported"
94+
}
95+
}
96+
]
97+
}
98+
""").build();
99+
79100
static final MockResponse FILE_NOT_SUPPORTED = new MockResponse.Builder().body("""
80101
{
81102
ok: true,

src/test/java/com/github/stickerifier/stickerify/bot/StickerifyTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@ void privacyMessage() throws Exception {
113113
}
114114
}
115115

116+
@Test
117+
void supportedMessage() throws Exception {
118+
server.enqueue(MockResponses.SUPPORTED_MESSAGE);
119+
120+
try (var _ = runBot()) {
121+
var getUpdates = server.takeRequest();
122+
assertEquals("/api/token/getUpdates", getUpdates.getTarget());
123+
124+
var sendRichMessage = server.takeRequest();
125+
assertEquals("/api/token/sendRichMessage", sendRichMessage.getTarget());
126+
assertResponseContainsMarkdownMessage(sendRichMessage, Answer.SUPPORTED_FORMATS);
127+
}
128+
}
129+
116130
@Test
117131
void fileNotSupported() throws Exception {
118132
server.enqueue(MockResponses.FILE_NOT_SUPPORTED);

0 commit comments

Comments
 (0)