Skip to content

Commit 479230d

Browse files
authored
Merge pull request #128 from akhromovRT/fix/message-reply-story-header-attribute
fix: handle MessageReplyStoryHeader without reply_to_msg_id attribute
2 parents 5bd5d6c + 3d2452e commit 479230d

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

telegram_mcp/tools/messages.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,9 @@ async def list_messages(
576576
"date": msg.date,
577577
"text": sanitize_user_content(msg.message),
578578
}
579-
if msg.reply_to and msg.reply_to.reply_to_msg_id:
580-
record["reply_to"] = msg.reply_to.reply_to_msg_id
579+
reply_to_id = getattr(msg.reply_to, "reply_to_msg_id", None) if msg.reply_to else None
580+
if reply_to_id:
581+
record["reply_to"] = reply_to_id
581582
engagement = get_engagement_dict(msg)
582583
if engagement:
583584
record["engagement"] = engagement
@@ -1077,8 +1078,9 @@ async def get_history(chat_id: Union[int, str], limit: int = 100, account: str =
10771078
"date": msg.date,
10781079
"text": sanitize_user_content(msg.message),
10791080
}
1080-
if msg.reply_to and msg.reply_to.reply_to_msg_id:
1081-
record["reply_to"] = msg.reply_to.reply_to_msg_id
1081+
reply_to_id = getattr(msg.reply_to, "reply_to_msg_id", None) if msg.reply_to else None
1082+
if reply_to_id:
1083+
record["reply_to"] = reply_to_id
10821084
records.append(record)
10831085
return format_tool_result(records)
10841086
except Exception as e:

0 commit comments

Comments
 (0)