Update send_message.py#89
Conversation
Некорректно шлёт сообщения, если указан parse_mode.
|
|
||
| if self.format is not None: | ||
| json["format"] = self.format.value | ||
| json["format"] = self.format |
There was a problem hiding this comment.
Отличная находка!
Было бы здорово добавить тест, проверяющий регрессию в этой части (например, прямую передачу 'HTML' без использования enum)
There was a problem hiding this comment.
Pull request overview
PR aims to fix incorrect message sending when parse_mode/format is specified by adjusting how the format field is placed into the JSON payload for the POST /messages API call.
Changes:
- Updated
SendMessage.fetch()to sendformatin the JSON payload without using.value.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| if self.format is not None: | ||
| json["format"] = self.format.value | ||
| json["format"] = self.format |
There was a problem hiding this comment.
json["format"] is now set to self.format (a ParseMode/TextFormat enum), while the rest of the codebase (e.g., EditMessage.fetch) serializes enums via .value, and existing tests assert the string value is sent (see tests/test_format_parameter.py::test_send_message_fetch_uses_format_in_json). This change will likely break tests and introduces inconsistent request payload types. Consider normalizing to a plain string (e.g., str(self.format) or .value with a fallback for already-string inputs) and update/add tests accordingly if supporting raw string parse_mode is the goal.
| json["format"] = self.format | |
| json["format"] = getattr(self.format, "value", self.format) |
|
Привет! Отличная находка с Эта проблема уже решена в PR #91 (замерджен), где:
Возможно, этот PR можно закрыть? |
Некорректно шлёт сообщения, если указан parse_mode.