← Back to PRs

#22434: feat(telegram): support sending original quality images

by godenjan open 2026-02-21 05:03 View on GitHub →
channel: telegram size: XS
Add mediaOptimize config option to Telegram channel. When mediaOptimize is set to false, images are sent as documents instead of compressed photos to preserve original quality. - Add asFile option to TelegramSendOpts - Update image sending logic to use sendDocument when asFile is true - Add mediaOptimize option to TelegramAccountSchemaBase - Update outbound adapter to read config and pass asFile flag Closes #22014 ## Summary - Problem: Images sent via Telegram are compressed to 800px + quality 40, resulting in significant quality loss - Why it matters: Users need to send high-quality images (posters, designs) but cannot preserve original quality - What changed: Added mediaOptimize config option - when set to false, images are sent as Documents (no compression) - What did NOT change: Default behavior remains the same (compression enabled by default) ## Change Type (select all) - [x] Feature ## Scope (select all touched areas) - [x] Integrations ## Linked Issue/PR - Closes #22014 ## User-visible / Behavior Changes - New config option: `channels.telegram.mediaOptimize` - When set to `false`, images are sent as Documents (files) to preserve original quality ## Security Impact (required) - New permissions/capabilities? No - Secrets/tokens handling changed? No - New/changed network calls? No - Command/tool execution surface changed? No - Data access scope changed? No ## Human Verification (required) - Verified scenarios: Code implemented and pushed to fork - Edge cases checked: Default behavior unchanged (mediaOptimize defaults to true) - What you did NOT verify: Actual runtime testing ## Compatibility / Migration - Backward compatible? Yes - Config/env changes? Yes (new optional config option) - Migration needed? No <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds a `mediaOptimize` config option to the Telegram channel that, when set to `false`, sends images as documents (via `sendDocument`) instead of compressed photos (via `sendPhoto`), preserving original quality. The implementation touches the Zod schema, the outbound adapter (both `sendMedia` and `sendPayload` paths), and the send function's media routing logic. - The Zod schema in `TelegramAccountSchemaBase` was updated, but the corresponding manual TypeScript type `TelegramAccountConfig` in `src/config/types.telegram.ts` was **not updated** — this will cause a TypeScript compilation error when accessing `resolved.config.mediaOptimize`. - The import of `resolveTelegramAccount` in the outbound adapter uses `"openclaw/plugin-sdk"` instead of a relative import, which is inconsistent with all other core `src/` files. - The `asFile` handling in `send.ts` is clean and correctly scoped to the `kind === "image"` branch only. <h3>Confidence Score: 2/5</h3> - This PR will likely fail TypeScript compilation due to a missing type update, blocking mergeability. - The core feature logic is sound, but the `TelegramAccountConfig` type in `src/config/types.telegram.ts` was not updated to include `mediaOptimize`, which means `resolved.config.mediaOptimize` will be a type error. This is a build-blocking issue. The import convention issue is minor but worth fixing. - Pay close attention to `src/config/types.telegram.ts` (missing type update) and `src/channels/plugins/outbound/telegram.ts` (import convention). <sub>Last reviewed commit: f501418</sub> <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs