Repository navigation
fix(contacts): find direct chat when get_contact_chats is called with a username - #308
Merged
chigwell merged 1 commit intoOct 17, 2026
Conversation
…t_chats get_contact_chats compared dialog.entity.id against the raw contact_id argument, so a username string never matched any dialog (int vs str, always False) and the tool reported "No chats found". Compare against the resolved contact.id instead, mirroring get_direct_chat_by_contact. Fixes chigwell#297 (chigwell/telegram-mcp) Co-Authored-By: Claude Code <[email protected]>
chigwell
approved these changes
Oct 17, 2026
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.
What changed
get_contact_chatscompareddialog.entity.id == contact_id, wherecontact_idis the raw argument: for a username call it is a string, so the int-vs-str comparison was always False and the direct chat was never matched. The comparison now uses the resolvedcontact.id, mirroringget_direct_chat_by_contact(contacts.py:163).Before
Contact Alice (id=999,
@alice_smith) has an existing private chat:Same contact: the username lookup reported nothing, the numeric lookup worked.
After
Same contact, same calls:
Both forms now return the private chat; the numeric path is unchanged.
Tests
tests/test_contact_chats.py: direct chat found by@username(failed before) + numeric-id regression case.uv run pytest -q→ 1196 passed.Fixes #297
🤖 Generated with Claude Code