mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-07-28 14:29:30 +00:00
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:
@@ -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)
|
||||
|
||||
+1142
-27
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user