diff options
| -rw-r--r-- | src/umabot/rules/roleplay_media_required.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/umabot/rules/roleplay_media_required.py b/src/umabot/rules/roleplay_media_required.py index e632716..5592044 100644 --- a/src/umabot/rules/roleplay_media_required.py +++ b/src/umabot/rules/roleplay_media_required.py @@ -25,9 +25,9 @@ class RoleplayMediaRequiredRule(Rule): if self._has_media(submission): return False - # Roleplay post without media - should be removed + # In-character post without media - should be removed self.logger.info( - f"Roleplay post by {submission.author.name} removed for missing media " + f"In-character post by {submission.author.name} removed for missing media " f"(post ID: {submission.id})" ) return True @@ -35,8 +35,8 @@ class RoleplayMediaRequiredRule(Rule): def get_removal_message(self, submission: praw.models.Submission) -> str: """Get the media requirement removal message.""" return ( - f"Your roleplay post has been removed because it doesn't include any media. " - f"All roleplay posts in r/{self.config.subreddit_name} must include an image, video, " + f"Your in-character post has been removed because it doesn't include any media. " + f"All in-character posts in r/{self.config.subreddit_name} must include an image, video, " f"or other media attachment." ) @@ -60,10 +60,17 @@ class RoleplayMediaRequiredRule(Rule): def _has_media(self, submission: praw.models.Submission) -> bool: """Check if a submission has media attached.""" try: - # Check for image/video posts - if submission.is_video or submission.is_self: - # For self posts, check if they contain media links - if submission.is_self and submission.selftext: + # Check for video posts (these have media) + if getattr(submission, 'is_video', False): + return True + + # Check for gallery posts (these have media) + if getattr(submission, 'is_gallery', False): + return True + + # Check for self posts (text posts that might contain media links) + if getattr(submission, 'is_self', False): + if submission.selftext: # Look for common media URLs in the text media_indicators = [ 'imgur.com', 'i.imgur.com', 'redd.it', 'i.redd.it', @@ -96,10 +103,6 @@ class RoleplayMediaRequiredRule(Rule): if any(domain in url_lower for domain in media_domains): return True - # Check for gallery posts - if hasattr(submission, 'is_gallery') and submission.is_gallery: - return True - # Check for crosspost with media if hasattr(submission, 'crosspost_parent') and submission.crosspost_parent: return self._has_media(submission.crosspost_parent) |