Skip to content

Commit 9a6e276

Browse files
artgas1claude
andcommitted
style: rewrite comments and docstrings in English
Address review feedback on PR #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>
1 parent 54d499c commit 9a6e276

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

telegram_mcp/tools/messages.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ def get_media_label(msg) -> str:
1313
msg.message but the media stays in msg.media).
1414
"""
1515
try:
16-
# Веб-превью ссылки — НЕ вложение. Проверяем ПЕРВЫМ: у сообщения со
17-
# ссылкой Telethon отдаёт картинку превью через msg.photo, иначе она
18-
# ложно пометилась бы как "photo".
16+
# Link web preview is NOT an attachment. Check it FIRST: for a message with a
17+
# link, Telethon returns the preview image via msg.photo; otherwise it would
18+
# be incorrectly classified as a "photo".
1919
if getattr(msg, "web_preview", None) is not None:
2020
return ""
21-
# Стикер/голос/видео/аудио/гиф — это тоже document, проверяем РАНЬШЕ document.
21+
# Sticker/voice/video/audio/GIF are also represented as documents, so check
22+
# them BEFORE the generic document handler.
2223
sticker = getattr(msg, "sticker", None)
2324
if sticker is not None:
2425
alt = ""
@@ -60,7 +61,7 @@ def get_media_label(msg) -> str:
6061

6162

6263
def _inline_button_texts(msg):
63-
"""Тексты inline-кнопок сообщения (плоским списком), [] если нет."""
64+
"""Inline button texts of the message (flat list), [] if none."""
6465
out = []
6566
try:
6667
for row in (getattr(msg, "buttons", None) or []):
@@ -74,7 +75,7 @@ def _inline_button_texts(msg):
7475

7576

7677
def _link_urls(msg):
77-
"""Явные URL из entities (скрытые за текстом ссылки), [] если нет."""
78+
"""Explicit URLs from entities (links hidden behind text), [] if none."""
7879
out = []
7980
try:
8081
for e in (getattr(msg, "entities", None) or []):
@@ -87,11 +88,12 @@ def _link_urls(msg):
8788

8889

8990
def message_to_dict(msg) -> dict:
90-
"""API-полный, но компактный вид сообщения Telethon (пустые поля опускаем).
91+
"""API-complete but compact Telethon message view (omit empty fields).
9192
92-
Цель — чтобы вывод MCP по полноте соответствовал объекту API, а не терял
93-
данные (медиа, альбомы, пересылки, правки, кнопки, реакции и т.п.).
94-
Все эти поля уже приходят в объекте сообщения тем же запросом get_messages.
93+
The goal is for the MCP output to match the API object in completeness, rather
94+
than losing data such as media, albums, forwards, edits, buttons, reactions,
95+
and so on. All these fields are already present in the message object returned
96+
by the same get_messages request.
9597
"""
9698
d = {"id": msg.id, "sender": get_sender_name(msg), "date": msg.date}
9799

@@ -111,7 +113,7 @@ def message_to_dict(msg) -> dict:
111113

112114
grouped_id = getattr(msg, "grouped_id", None)
113115
if grouped_id:
114-
d["grouped_id"] = grouped_id # альбом: сообщения с одним grouped_id — одна группа
116+
d["grouped_id"] = grouped_id # album: messages sharing one grouped_id form a single group
115117

116118
reply_to_id = getattr(msg.reply_to, "reply_to_msg_id", None) if getattr(msg, "reply_to", None) else None
117119
if reply_to_id:
@@ -159,7 +161,7 @@ def message_to_dict(msg) -> dict:
159161

160162
action = getattr(msg, "action", None)
161163
if action is not None:
162-
d["action"] = type(action).__name__ # сервисное сообщение (вступил/закрепил/…)
164+
d["action"] = type(action).__name__ # service message (joined/pinned/…)
163165

164166
ttl = getattr(msg, "ttl_period", None)
165167
if ttl:
@@ -169,7 +171,7 @@ def message_to_dict(msg) -> dict:
169171

170172

171173
def format_message_line(msg) -> str:
172-
"""Однострочный человекочитаемый вид сообщения со ВСЕМИ ключевыми флагами."""
174+
"""Single-line human-readable message representation with ALL key flags."""
173175
parts = [f"ID: {msg.id}", get_sender_name(msg), f"Date: {msg.date}"]
174176

175177
reply_to_id = getattr(msg.reply_to, "reply_to_msg_id", None) if getattr(msg, "reply_to", None) else None

0 commit comments

Comments
 (0)