diff options
| author | Fuwn <[email protected]> | 2025-09-16 14:55:03 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-09-16 14:55:03 -0700 |
| commit | 51dd2e7533c2370f3bbf45d2dd98dc17268b20c7 (patch) | |
| tree | 13c7b6951bedb4ad50822a96a5a44e006ac42c50 /src | |
| parent | feat(roleplay_limiter): Lower surge thresholds (diff) | |
| download | umabot-51dd2e7533c2370f3bbf45d2dd98dc17268b20c7.tar.xz umabot-51dd2e7533c2370f3bbf45d2dd98dc17268b20c7.zip | |
feat(roleplay_limiter): Use updated removal message format
Diffstat (limited to 'src')
| -rw-r--r-- | src/umabot/rules/roleplay_limiter.py | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/src/umabot/rules/roleplay_limiter.py b/src/umabot/rules/roleplay_limiter.py index cc261fa..be6de10 100644 --- a/src/umabot/rules/roleplay_limiter.py +++ b/src/umabot/rules/roleplay_limiter.py @@ -1,6 +1,7 @@ """Surge-based roleplay post limiter rule.""" import time +from datetime import datetime, timedelta, timezone from typing import Dict, List import praw.models from .base import Rule @@ -63,24 +64,40 @@ class RoleplayLimiter(Rule): return False def get_removal_message(self, submission: praw.models.Submission) -> str: - """Get the dynamic roleplay removal message.""" + """Get the dynamic roleplay removal message with time remaining until limit expires.""" surge_level, user_limit = self._get_surge_level_and_limit() + username = submission.author.name if submission.author else "Unknown" + current_utc = datetime.now(timezone.utc) + + # Calculate time until next UTC day (midnight UTC) + next_day = current_utc.replace(hour=0, minute=0, second=0, microsecond=0) + timedelta(days=1) + time_remaining = next_day - current_utc + + # Format time remaining + hours = int(time_remaining.total_seconds() // 3600) + minutes = int((time_remaining.total_seconds() % 3600) // 60) + + if hours > 0: + time_str = f"{hours}h {minutes}m" + else: + time_str = f"{minutes}m" + + base_message = ( + f"Your post has been removed. Due to high roleplay activity " + f"({surge_level} roleplay posts in the last {self.config.roleplay_limit_window_hours} hours), " + ) if user_limit == 0: - return ( - f"Your post has been removed. Due to high roleplay activity " - f"({surge_level} roleplay posts in the last {self.config.roleplay_limit_window_hours} hours), " - f"roleplay posts are temporarily restricted in r/{self.config.subreddit_name}. " - f"This subreddit uses a surge-based system that dynamically adjusts limits based on overall activity." - ) + main_message = f"roleplay posts are temporarily restricted in r/{self.config.subreddit_name}. " else: - return ( - f"Your post has been removed. Due to high roleplay activity " - f"({surge_level} roleplay posts in the last {self.config.roleplay_limit_window_hours} hours), " + main_message = ( f"users in r/{self.config.subreddit_name} can submit {user_limit} roleplay post(s) " f"within a {self.config.roleplay_limit_window_hours}-hour time window. " - f"This subreddit uses a surge-based system that dynamically adjusts limits based on overall activity." ) + + notice = f"\n\nThis subreddit uses a surge-based system that dynamically adjusts limits based on overall activity. Your limit resets in {time_str}." + + return base_message + main_message + notice def _get_surge_level_and_limit(self) -> tuple[int, int]: """Get current surge level and corresponding user limit.""" |