mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-03-30 20:15:40 +00:00
fix: Improve weather string handling to prevent emoji truncation
- Updated the weather string concatenation logic to use display width for checking available space, ensuring emojis are not cut off. - Added a buffer of 5 characters to the maximum length check to enhance the user experience when displaying weather information.
This commit is contained in:
@@ -635,7 +635,9 @@ class GlobalWxCommand(BaseCommand):
|
||||
# Only show probability if no amount available
|
||||
precip_str = f" 🌦️{precip_prob}%"
|
||||
|
||||
if len(weather + precip_str) <= max_length:
|
||||
# Use display width to check if we have space, with buffer to avoid cutting emojis
|
||||
# Add buffer of 5 chars to ensure we don't truncate in middle of emoji
|
||||
if self._count_display_width(weather + precip_str) <= max_length - 5:
|
||||
weather += precip_str
|
||||
|
||||
return weather
|
||||
|
||||
Reference in New Issue
Block a user