Skip to content

Commit

Permalink
Fix trimming too long messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Electronic-Mango committed Nov 28, 2023
1 parent ca0f721 commit f898448
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main/bot/sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ def _prepare_url_keyboard(link: str) -> InlineKeyboardMarkup:
return InlineKeyboardMarkup(keyboard)


def _trim_message(chat_id: int, message: str, appended_size: int) -> str:
effective_max_message_size = MAX_MESSAGE_SIZE - appended_size
if len(message) > effective_max_message_size:
def _trim_message(chat_id: int, message: str) -> str:
if len(message) > MAX_MESSAGE_SIZE:
_logger.info(f"[{chat_id}] Trimming message")
effective_max_number_of_characters = effective_max_message_size - len("...")
effective_max_number_of_characters = MAX_MESSAGE_SIZE - len("...")
message = f"{message[:effective_max_number_of_characters]}..."
return message

Expand Down

0 comments on commit f898448

Please sign in to comment.