feat: full-fidelity message data in get_history / get_messages - #133
Merged
chigwell merged 2 commits intoJun 3, 2026
Merged
Conversation
Listings were lossy — they returned only id/sender/date/reply/text and dropped everything else the Telethon message object already carries in the same response. Now they reflect the API object faithfully. - New message_to_dict(msg): media, grouped_id (album), reply_to, forwarded, via_bot_id, edited, pinned, engagement (views/forwards/reactions), comments, inline buttons, link_urls (hidden entity URLs), service action, ttl_period, sender_id, out. Empty fields omitted. - get_history → returns these full dicts (JSON via format_tool_result). - get_messages → format_message_line with all key flags (📎 media, album, forwarded, edited, via_bot, pinned, buttons, service) + [empty] for no text. - Fix get_media_label: check web_preview BEFORE photo so link-preview images are not mislabeled as "📎 photo". No extra API calls — all data is already on the fetched message. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
chigwell
requested changes
May 26, 2026
| try: | ||
| # стикер/голос/видео/аудио/гиф — это тоже document, поэтому проверяем их РАНЬШЕ document | ||
| # Веб-превью ссылки — НЕ вложение. Проверяем ПЕРВЫМ: у сообщения со | ||
| # ссылкой Telethon отдаёт картинку превью через msg.photo, иначе она |
Owner
There was a problem hiding this comment.
Suggested change
| # ссылкой Telethon отдаёт картинку превью через msg.photo, иначе она | |
| # link, Telethon returns the preview image via msg.photo; otherwise it would |
| # стикер/голос/видео/аудио/гиф — это тоже document, поэтому проверяем их РАНЬШЕ document | ||
| # Веб-превью ссылки — НЕ вложение. Проверяем ПЕРВЫМ: у сообщения со | ||
| # ссылкой Telethon отдаёт картинку превью через msg.photo, иначе она | ||
| # ложно пометилась бы как "photo". |
Owner
There was a problem hiding this comment.
Suggested change
| # ложно пометилась бы как "photo". | |
| # be incorrectly classified as a "photo". |
| # ложно пометилась бы как "photo". | ||
| if getattr(msg, "web_preview", None) is not None: | ||
| return "" | ||
| # Стикер/голос/видео/аудио/гиф — это тоже document, проверяем РАНЬШЕ document. |
Owner
There was a problem hiding this comment.
Suggested change
| # Стикер/голос/видео/аудио/гиф — это тоже document, проверяем РАНЬШЕ document. | |
| # Sticker/voice/video/audio/GIF are also represented as documents, so check | |
| # them BEFORE the generic document handler. |
|
|
||
|
|
||
| def _inline_button_texts(msg): | ||
| """Тексты inline-кнопок сообщения (плоским списком), [] если нет.""" |
Owner
There was a problem hiding this comment.
Suggested change
| """Тексты inline-кнопок сообщения (плоским списком), [] если нет.""" | |
| """Inline button texts of the message (flat list), [] if none.""" |
|
|
||
|
|
||
| def message_to_dict(msg) -> dict: | ||
| """API-полный, но компактный вид сообщения Telethon (пустые поля опускаем). |
Owner
There was a problem hiding this comment.
Suggested change
| """API-полный, но компактный вид сообщения Telethon (пустые поля опускаем). | |
| """API-complete but compact Telethon message view (omit empty fields). |
| def message_to_dict(msg) -> dict: | ||
| """API-полный, но компактный вид сообщения Telethon (пустые поля опускаем). | ||
|
|
||
| Цель — чтобы вывод MCP по полноте соответствовал объекту API, а не терял |
Owner
There was a problem hiding this comment.
Suggested change
| Цель — чтобы вывод MCP по полноте соответствовал объекту API, а не терял | |
| The goal is for the MCP output to match the API object in completeness, rather |
| """API-полный, но компактный вид сообщения Telethon (пустые поля опускаем). | ||
|
|
||
| Цель — чтобы вывод MCP по полноте соответствовал объекту API, а не терял | ||
| данные (медиа, альбомы, пересылки, правки, кнопки, реакции и т.п.). |
Owner
There was a problem hiding this comment.
Suggested change
| данные (медиа, альбомы, пересылки, правки, кнопки, реакции и т.п.). | |
| than losing data such as media, albums, forwards, edits, buttons, reactions, |
|
|
||
| Цель — чтобы вывод MCP по полноте соответствовал объекту API, а не терял | ||
| данные (медиа, альбомы, пересылки, правки, кнопки, реакции и т.п.). | ||
| Все эти поля уже приходят в объекте сообщения тем же запросом get_messages. |
Owner
There was a problem hiding this comment.
Suggested change
| Все эти поля уже приходят в объекте сообщения тем же запросом get_messages. | |
| and so on. All these fields are already present in the message object returned | |
| by the same get_messages request. |
|
|
||
|
|
||
| def format_message_line(msg) -> str: | ||
| """Однострочный человекочитаемый вид сообщения со ВСЕМИ ключевыми флагами.""" |
Owner
There was a problem hiding this comment.
Suggested change
| """Однострочный человекочитаемый вид сообщения со ВСЕМИ ключевыми флагами.""" | |
| """Single-line human-readable message representation with ALL key flags.""" |
artgas1
added a commit
to artgas1/telegram-mcp
that referenced
this pull request
Jun 3, 2026
Address review feedback on PR chigwell#133: translate all comments and docstrings in telegram_mcp/tools/messages.py to English for codebase consistency. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
artgas1
force-pushed
the
feat/full-message-fidelity-upstream
branch
from
June 3, 2026 15:44
45e9832 to
9a6e276
Compare
Address review feedback on PR chigwell#133: translate all comments and docstrings in telegram_mcp/tools/messages.py to English for codebase consistency. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
artgas1
force-pushed
the
feat/full-message-fidelity-upstream
branch
from
June 3, 2026 17:42
9a6e276 to
fd69b8b
Compare
Contributor
Author
|
Thanks for the review, @chigwell! All comments and docstrings in |
chigwell
approved these changes
Jun 3, 2026
KiaroSama
pushed a commit
to KiaroSama/telegram-mcp
that referenced
this pull request
Aug 25, 2026
Address review feedback on PR chigwell#133: translate all comments and docstrings in telegram_mcp/tools/messages.py to English for codebase consistency. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
KiaroSama
pushed a commit
to KiaroSama/telegram-mcp
that referenced
this pull request
Aug 25, 2026
…ty-upstream feat: full-fidelity message data in get_history / get_messages
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.
Problem
get_history/get_messageswere lossy: they returned only id/sender/date/reply/text (+ the recently added media flag) and dropped everything else the Telethon message object already carries in the same response. So albums, forwards, edits, inline buttons, hidden link URLs, service messages etc. were invisible without extra calls.Change
message_to_dict(msg)— API-faithful, compact (empty fields omitted): media, grouped_id (album), reply_to, forwarded (date/from_name), via_bot_id, edited, pinned, engagement (views/forwards/reactions), comments, inline buttons, link_urls (entity URLs), service action, ttl_period, sender_id, out.get_history→ returns these full dicts (JSON via format_tool_result).get_messages→format_message_linewith all key flags (📎 media, album, forwarded, edited, via_bot, pinned, buttons, service) and[empty]when no text.get_media_label: checkweb_previewbeforephotoso link-preview images aren't mislabeled📎 photo.No extra API calls — all data is already on the fetched message. Builds on #132.
🤖 Generated with Claude Code