Refine command manager logging and enhance weather command alert handling

- Updated CommandManager to log rate limiting warnings only for meaningful wait times, avoiding misleading messages.
- Enhanced WxCommand to support a new "alerts" keyword for fetching weather alerts, with special handling for alert data.
- Improved alert fetching logic to differentiate duplicate special statements and prioritize alerts based on severity and urgency.
- Added methods for compactly formatting alerts and abbreviating city names for better display in responses.
This commit is contained in:
agessaman
2025-12-16 18:28:26 -08:00
parent 399a6b9773
commit f0b4f1e078
2 changed files with 1150 additions and 29 deletions
+8 -2
View File
@@ -232,7 +232,10 @@ class CommandManager:
# Check user rate limiter (prevents spam from users)
if not self.bot.rate_limiter.can_send():
wait_time = self.bot.rate_limiter.time_until_next()
self.logger.warning(f"Rate limited. Wait {wait_time:.1f} seconds")
# Only log warning if there's a meaningful wait time (> 0.1 seconds)
# This avoids misleading "Wait 0.0 seconds" messages from timing edge cases
if wait_time > 0.1:
self.logger.warning(f"Rate limited. Wait {wait_time:.1f} seconds")
return False
# Wait for bot TX rate limiter (prevents network overload)
@@ -325,7 +328,10 @@ class CommandManager:
# Check user rate limiter (prevents spam from users)
if not self.bot.rate_limiter.can_send():
wait_time = self.bot.rate_limiter.time_until_next()
self.logger.warning(f"Rate limited. Wait {wait_time:.1f} seconds")
# Only log warning if there's a meaningful wait time (> 0.1 seconds)
# This avoids misleading "Wait 0.0 seconds" messages from timing edge cases
if wait_time > 0.1:
self.logger.warning(f"Rate limited. Wait {wait_time:.1f} seconds")
return False
# Wait for bot TX rate limiter (prevents network overload)
File diff suppressed because it is too large Load Diff