Skip to content

Commit

Permalink
fix: max_len case where split_index does not match, closes #45
Browse files Browse the repository at this point in the history
  • Loading branch information
Helias committed May 31, 2023
1 parent 7f73720 commit 4d8936e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions module/scraping/notice.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,13 @@ def formatted_content(self) -> str:
if len(content) > max_len:
split_index = max_len - 1

while content[split_index] != " ":
split_index = split_index - 1
try:
while content[split_index] != " ":
split_index = split_index - 1
except Exception as e:
# fix for https://github.com/UNICT-DMI/Telegram-UNICT-Bot/issues/45
print(str(e))
return f"{content[:max_len-1]}{config_map['max_length_footer']}"

content = f"{content[:split_index]}{config_map['max_length_footer']}"

Expand Down

0 comments on commit 4d8936e

Please sign in to comment.