Skip to content

fix(messages): list_messages never calls get_media_label - #196

Merged
chigwell merged 1 commit into
chigwell:mainfrom
khairutdinov-personal:fix/list-messages-media-label
Aug 21, 2026
Merged

fix(messages): list_messages never calls get_media_label#196
chigwell merged 1 commit into
chigwell:mainfrom
khairutdinov-personal:fix/list-messages-media-label

Conversation

@PathKnower

Copy link
Copy Markdown
Contributor

Summary

  • list_messages builds its own record dict directly from msg.message, without the get_media_label(msg) fallback that message_to_dict (used by get_history) already has.
  • Net effect: a voice message, photo, sticker, or any other captionless media item shows up in list_messages output looking identical to an actually-empty message — no media field, no indication anything was attached.
  • Fix adds the same one-line get_media_label call message_to_dict already does, so list_messages records get a media field (e.g. "media": "voice", "media": "photo") whenever the message carries media, whether or not there's a caption.

Test plan

uv run pytest tests/ -q
# 281 passed
uv run pre-commit run --files telegram_mcp/tools/messages.py
black....................................................................Passed
flake8...................................................................Passed

Manually confirmed against a real chat with several voice/photo messages via a running server — list_messages now reports "media": "voice" for a voice message that previously showed no media indicator at all.

record["text"] was built directly from msg.message without falling back to
get_media_label(msg), so a voice message, photo, or any other captionless
media item rendered identically to an actually-empty message. message_to_dict
(used by get_history) already handled this correctly.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@chigwell
chigwell merged commit 817d0b7 into chigwell:main Aug 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants