Fix #170: support .svelte and other code files with unrecognized MIME types#173
Merged
Merged
Conversation
Support .svelte, .vue, .tsx, .py, .go, and 40+ other code file extensions when Telegram sends an unrecognized or generic MIME type (e.g. application/octet-stream). This fixes grinev#170 — .svelte files (and similar code files) are now correctly identified as text content instead of being rejected as unsupported. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
hbx12
added a commit
to hbx12/opencode-telegram-bot
that referenced
this pull request
Jul 1, 2026
…am's 4096-byte limit Rework truncation to use Buffer.byteLength() instead of character count. Telegram's editMessageText limit is 4096 bytes (not characters), so non-ASCII prompts (Arabic, Cyrillic, CJK) still crashed with the previous character-based fix. Binary search approach finds the correct character offset efficiently. Also removes the svelte MIME type fallback changes from this PR — they now live in a separate PR (grinev#173). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Owner
|
@hbx12 thanks for contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
🐛 #170 — Cannot send .svelte files (and other code files with unrecognized MIME types)
application/octet-stream), so the bot rejects them as unsupportedisTextMimeType()— when the MIME type is unknown, the function now checks the file extension against a list of 40+ common code file extensions (.svelte,.vue,.tsx,.py,.go,.rs, etc.)Files changed
file-download-service.ts— addedTEXT_FILE_EXTENSIONSset + filename parameter inisTextMimeType()document-handler.ts— pass filename toisTextMimeType()media-group-handler.ts— pass filename toisTextMimeType()✅ TypeScript — zero errors
✅ Tests added for new behavior