diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/umabot/config.py | 4 | ||||
| -rw-r--r-- | src/umabot/rules/intelligent_roleplay_moderator.py | 74 |
2 files changed, 72 insertions, 6 deletions
diff --git a/src/umabot/config.py b/src/umabot/config.py index ab03a25..af53e87 100644 --- a/src/umabot/config.py +++ b/src/umabot/config.py @@ -36,6 +36,9 @@ class Config: roleplay_limit_window_hours: int = 24 # hours dry_run: bool = False + # Mod mail reasoning level (0=none, 1=brief, 2=full) + reasoning_level: int = 2 + @classmethod def from_env(cls) -> "Config": """Create configuration from environment variables.""" @@ -57,6 +60,7 @@ class Config: post_limit_window_hours=int(os.getenv("POST_LIMIT_WINDOW_HOURS", "24")), roleplay_limit_window_hours=int(os.getenv("ROLEPLAY_LIMIT_WINDOW_HOURS", "24")), dry_run=os.getenv("DRY_RUN", "false").lower() == "true", + reasoning_level=int(os.getenv("REASONING_LEVEL", "2")), ) def validate(self) -> None: diff --git a/src/umabot/rules/intelligent_roleplay_moderator.py b/src/umabot/rules/intelligent_roleplay_moderator.py index 92ee9d1..ab6f61e 100644 --- a/src/umabot/rules/intelligent_roleplay_moderator.py +++ b/src/umabot/rules/intelligent_roleplay_moderator.py @@ -107,11 +107,18 @@ class IntelligentRoleplayModerator(Rule, IntelligentModeratorBase): username = submission.author.name subject = "Your post flair has been changed to Art" + # Format reasoning based on configuration + formatted_reasoning = self._format_reasoning(evaluation) + message = f"""Hello u/{username}, -Your roleplay post has been automatically re-flaired as "Art" because it appears to be primarily showcasing artwork or visual content rather than roleplay. - -Reasoning: {evaluation['reasoning']} +Your roleplay post has been automatically re-flaired as "Art" because it appears to be primarily showcasing artwork or visual content rather than roleplay.""" + + # Add reasoning if configured + if formatted_reasoning: + message += f"\n\nReasoning: {formatted_reasoning}" + + message += f""" Post link: https://reddit.com{submission.permalink} @@ -131,11 +138,18 @@ Thank you for understanding!""" username = submission.author.name subject = "Your roleplay post has been removed for low effort" + # Format reasoning based on configuration + formatted_reasoning = self._format_reasoning(evaluation) + message = f"""Hello u/{username}, -Your roleplay post has been removed because it was determined to be low-effort content. - -Reasoning: {evaluation['reasoning']} +Your roleplay post has been removed because it was determined to be low-effort content.""" + + # Add reasoning if configured + if formatted_reasoning: + message += f"\n\nReasoning: {formatted_reasoning}" + + message += f""" Post link: https://reddit.com{submission.permalink} @@ -155,6 +169,54 @@ Thank you for understanding!""" except Exception as e: self.logger.error(f"Error sending low effort notification for {submission.id}: {e}") + def _format_reasoning(self, evaluation: dict) -> str: + """Format reasoning based on the configured reasoning level.""" + reasoning_level = self.config.reasoning_level + original_reasoning = evaluation.get('reasoning', '') + + if reasoning_level == 0: + # No reasoning included + return "" + elif reasoning_level == 1: + # Brief reasoning - extract key points + return self._extract_brief_reasoning(original_reasoning) + else: + # Full reasoning (default) + return original_reasoning + + def _extract_brief_reasoning(self, reasoning: str) -> str: + """Extract brief key points from the full reasoning.""" + # Convert to lowercase for easier processing + reasoning_lower = reasoning.lower() + + # Extract key issues + issues = [] + + # Check for common low-effort indicators + if any(word in reasoning_lower for word in ['short', 'brief', 'minimal', 'little']): + issues.append('short') + if any(word in reasoning_lower for word in ['word count', 'words', 'length']): + issues.append('low word count') + if any(word in reasoning_lower for word in ['plot', 'story', 'narrative']): + if 'no plot' in reasoning_lower or 'lack' in reasoning_lower: + issues.append('no plot development') + if any(word in reasoning_lower for word in ['effort', 'substance', 'content']): + if 'low' in reasoning_lower or 'lack' in reasoning_lower: + issues.append('low effort') + if any(word in reasoning_lower for word in ['creativity', 'originality']): + if 'lack' in reasoning_lower or 'no' in reasoning_lower: + issues.append('lacks creativity') + if any(word in reasoning_lower for word in ['artwork', 'art', 'visual', 'image']): + if 'primarily' in reasoning_lower or 'showcasing' in reasoning_lower: + issues.append('artwork showcase') + + # If no specific issues found, return a generic brief message + if not issues: + return "Content quality below standards" + + # Return comma-separated list of issues + return ", ".join(issues) + def _is_roleplay_post(self, submission: praw.models.Submission) -> bool: """Check if a submission has the roleplay flair.""" try: |