Skip to content

Switch replies to rich text#513

Open
rob93c wants to merge 7 commits into
mainfrom
reply-with-rich-text
Open

Switch replies to rich text#513
rob93c wants to merge 7 commits into
mainfrom
reply-with-rich-text

Conversation

@rob93c

@rob93c rob93c commented Jun 14, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

Release Notes

  • New Features

    • Added /supported command to display all supported file formats in a table.
    • Bot now displays a processing status message during file conversion.
    • Enhanced message formatting with improved text styling.
  • Tests

    • Updated test suite to validate rich message responses from the bot.

@rob93c rob93c requested a review from MartelliEnrico June 14, 2026 13:22
@rob93c rob93c self-assigned this Jun 14, 2026
@rob93c rob93c added enhancement New feature or request unit test This marks issues revolving around unit tests labels Jun 14, 2026
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The bot's text-response mechanism is migrated from SendMessage/MarkdownV2 to SendRichMessage/InputRichMessage.markdown. A PROCESSING draft message is now sent before file conversion begins. The Answer enum drops the disableLinkPreview API and gains PROCESSING and SUPPORTED_FORMATS constants. A new /supported command is wired into TelegramRequest. Tests are updated throughout to assert against sendRichMessage JSON payloads.

Changes

Rich-message migration and /supported command

Layer / File(s) Summary
Answer enum: contract simplification and new constants
src/main/java/com/github/stickerifier/stickerify/telegram/Answer.java
Removes disableLinkPreview field, constructor, and isDisableLinkPreview() method; reformats message text blocks; adds PROCESSING and SUPPORTED_FORMATS enum constants.
/supported command wiring
src/main/java/com/github/stickerifier/stickerify/telegram/model/TelegramRequest.java
Adds SUPPORTED_COMMAND constant and maps it to SUPPORTED_FORMATS in getAnswerMessage().
Stickerify bot: SendRichMessage and processing draft
src/main/java/com/github/stickerifier/stickerify/bot/Stickerify.java
Updates imports for rich-message types, introduces PROCESSING_MESSAGE draft, sends a SendRichMessageDraft before file conversion, removes FILE_READY caption from document send, and replaces SendMessage/MarkdownV2 in answerText with SendRichMessage.
Test infrastructure: mock responses and assertion helpers
src/test/java/com/github/stickerifier/stickerify/bot/MockResponses.java, src/test/java/com/github/stickerifier/stickerify/bot/StickerifyTest.java
Renames EMPTY_UPDATES to SUCCESS_RESPONSE, adds SUPPORTED_MESSAGE fixture, refactors assertResponseContainsMessage to parse rich_message JSON, and introduces assertResponseContainsMarkdownMessage and assertResponseContainsHtmlMessage helpers.
Test case updates for rich-message and /supported
src/test/java/com/github/stickerifier/stickerify/bot/StickerifyTest.java
Updates all test assertions to use /api/token/sendRichMessage, validates Markdown payloads for text responses, asserts HTML for draft processing messages, and covers the new /supported command.
Build: test logging
build.gradle
Adds started to testLogging events alongside passed, failed, and skipped.

Sequence Diagram(s)

sequenceDiagram
  participant Client as Telegram Client
  participant Stickerify as Stickerify Bot
  participant TelegramAPI as Telegram API

  rect rgba(173, 216, 230, 0.5)
    Note over Client, TelegramAPI: Text command (e.g. /start, /help, /supported)
    Client->>Stickerify: Command message
    Stickerify->>TelegramAPI: sendRichMessage(InputRichMessage.markdown(answer.getText()))
  end

  rect rgba(144, 238, 144, 0.5)
    Note over Client, TelegramAPI: File processing
    Client->>Stickerify: File upload
    Stickerify->>TelegramAPI: sendRichMessageDraft(PROCESSING_MESSAGE)
    Stickerify->>TelegramAPI: sendDocument(converted file)
    Stickerify->>TelegramAPI: sendRichMessage(InputRichMessage.markdown(FILE_READY.getText()))
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Stickerifier/Stickerify#332: Modifies the same Stickerify.java message-sending code path, specifically how reply targets are configured in the response flow.
  • Stickerifier/Stickerify#492: Alters Answer.java enum constants and the surrounding Stickerify response flow at the same interfaces changed here.
  • Stickerifier/Stickerify#403: Modifies the same StickerifyTest and MockResponses test infrastructure, including mock update constants and dispatcher configuration.

Suggested reviewers

  • MartelliEnrico

Poem

🐇 Hoppity hop, no plain text today,
Rich messages now hop along the way!
A /supported command joins the warren,
Draft "Processing…" notes — nothing's borin'.
The enum sheds its preview disguise,
And tests now parse JSON with bright eyes! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: migrating bot replies from plain text to Telegram's rich-text message format across the codebase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/github/stickerifier/stickerify/telegram/model/TelegramRequest.java (1)

83-88: ⚠️ Potential issue | 🟠 Major

Normalise bot commands by stripping the optional @username suffix before switching on message.text().

Telegram bot commands in group chats are sent with the bot's username appended (e.g. /start@MyBot_bot). The current implementation uses exact string matching, which will fail to recognise these commands and fall through to the default case, returning ABOUT instead of the correct answer. This affects both getAnswerMessage() and isNewUser(). Extract the command portion before the @ symbol or use a helper method to normalise the text before the switch.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/github/stickerifier/stickerify/telegram/model/TelegramRequest.java`
around lines 83 - 88, The switch statement in the getAnswerMessage() method (and
similarly in isNewUser()) operates directly on message.text() without
normalizing bot commands. Telegram bot commands in group chats include the
optional `@username` suffix (e.g., /start@MyBot_bot), so exact string matching
will fail to recognize these commands and fall through to the default case.
Create a helper method that extracts the command portion before the @ symbol (or
returns the full text if no @ is present), then use this normalized text in the
switch statement in both getAnswerMessage() and isNewUser() methods.
🧹 Nitpick comments (1)
src/main/java/com/github/stickerifier/stickerify/telegram/Answer.java (1)

47-69: ⚡ Quick win

Keep the rich-text format in the enum contract.

PROCESSING is HTML, while the other answers are markdown, but Answer now only exposes raw text. Downstream code already has to special-case Answer.PROCESSING in src/test/java/com/github/stickerifier/stickerify/bot/StickerifyTest.java Lines 64-66, so the contract is now split across files. Please add a RichMessageFormat/MessageFormat field to the enum and let callers read it instead of branching on specific enum values.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/github/stickerifier/stickerify/telegram/Answer.java` around
lines 47 - 69, The Answer enum currently mixes HTML and markdown formats without
exposing this information, forcing downstream code to special-case the
PROCESSING enum value. Add a RichMessageFormat (or MessageFormat) field to the
Answer enum to track whether each answer is HTML or markdown. Update each enum
constant (PROCESSING, SUPPORTED_FORMATS, and any others) to specify their
respective format, modify the Answer constructor to accept this format
parameter, and add a getter method (like getFormat()) to expose it. This allows
callers to check the format via the enum field instead of branching on specific
enum values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/com/github/stickerifier/stickerify/bot/Stickerify.java`:
- Around line 151-152: The order of operations in the file upload workflow is
incorrect. Currently, the FILE_READY message is sent via answerText before the
actual document upload via execute(answerWithFile), which means users could
receive a success notification even if the file upload fails. Reverse the order
of these two calls: execute the document send operation first using
answerWithFile, and then send the FILE_READY message via answerText only after
the upload completes successfully.

In `@src/main/java/com/github/stickerifier/stickerify/telegram/Answer.java`:
- Around line 50-59: The SUPPORTED_FORMATS constant now advertises support for
animated stickers alongside static and video stickers, but the HELP and ERROR
response constants still only reference standard and video sticker support.
Update both the HELP and ERROR message constants in the Answer class to include
animated stickers in their descriptions of supported sticker types, ensuring all
user-facing messages provide consistent guidance about the three supported
sticker formats.

---

Outside diff comments:
In
`@src/main/java/com/github/stickerifier/stickerify/telegram/model/TelegramRequest.java`:
- Around line 83-88: The switch statement in the getAnswerMessage() method (and
similarly in isNewUser()) operates directly on message.text() without
normalizing bot commands. Telegram bot commands in group chats include the
optional `@username` suffix (e.g., /start@MyBot_bot), so exact string matching
will fail to recognize these commands and fall through to the default case.
Create a helper method that extracts the command portion before the @ symbol (or
returns the full text if no @ is present), then use this normalized text in the
switch statement in both getAnswerMessage() and isNewUser() methods.

---

Nitpick comments:
In `@src/main/java/com/github/stickerifier/stickerify/telegram/Answer.java`:
- Around line 47-69: The Answer enum currently mixes HTML and markdown formats
without exposing this information, forcing downstream code to special-case the
PROCESSING enum value. Add a RichMessageFormat (or MessageFormat) field to the
Answer enum to track whether each answer is HTML or markdown. Update each enum
constant (PROCESSING, SUPPORTED_FORMATS, and any others) to specify their
respective format, modify the Answer constructor to accept this format
parameter, and add a getter method (like getFormat()) to expose it. This allows
callers to check the format via the enum field instead of branching on specific
enum values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5dcbf90b-4066-47e4-b60c-262f0f8fb91e

📥 Commits

Reviewing files that changed from the base of the PR and between f07ad20 and 23663dd.

📒 Files selected for processing (6)
  • build.gradle
  • src/main/java/com/github/stickerifier/stickerify/bot/Stickerify.java
  • src/main/java/com/github/stickerifier/stickerify/telegram/Answer.java
  • src/main/java/com/github/stickerifier/stickerify/telegram/model/TelegramRequest.java
  • src/test/java/com/github/stickerifier/stickerify/bot/MockResponses.java
  • src/test/java/com/github/stickerifier/stickerify/bot/StickerifyTest.java

Comment on lines +151 to 152
answerText(FILE_READY, request);
execute(answerWithFile);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Send the document before announcing it is ready.

At Line 151, FILE_READY is sent before the upload at Line 152. If sendDocument fails, users can receive a success message without a file (and then an error path). Execute the document send first, then send the ready text only on success.

Suggested fix
-				answerText(FILE_READY, request);
-				execute(answerWithFile);
+				execute(answerWithFile);
+				answerText(FILE_READY, request);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/github/stickerifier/stickerify/bot/Stickerify.java` around
lines 151 - 152, The order of operations in the file upload workflow is
incorrect. Currently, the FILE_READY message is sent via answerText before the
actual document upload via execute(answerWithFile), which means users could
receive a success notification even if the file upload fails. Reverse the order
of these two calls: execute the document send operation first using
answerWithFile, and then send the FILE_READY message via answerText only after
the upload completes successfully.

Comment on lines +50 to +59
SUPPORTED_FORMATS("""
| Type | Supported formats |
|:---------|:------------------------------------------------|
| images | png, jpg, static webp, tiff, ico, svg, psd |
| videos | gif, mov, avi, mp4, webm, m4v, mkv, live photos |
| stickers | static, video, animated |

If you have any questions or concerns, feel free to reach out to us\\.
---

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).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Keep the support copy consistent across replies.

SUPPORTED_FORMATS now advertises animated stickers, but HELP and ERROR still describe sticker support as only standard/video. Users will get different guidance depending on which reply they hit.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/github/stickerifier/stickerify/telegram/Answer.java` around
lines 50 - 59, The SUPPORTED_FORMATS constant now advertises support for
animated stickers alongside static and video stickers, but the HELP and ERROR
response constants still only reference standard and video sticker support.
Update both the HELP and ERROR message constants in the Answer class to include
animated stickers in their descriptions of supported sticker types, ensuring all
user-facing messages provide consistent guidance about the three supported
sticker formats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request unit test This marks issues revolving around unit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant