diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/umabot/bot.py | 38 | ||||
| -rw-r--r-- | src/umabot/config.py | 2 |
2 files changed, 32 insertions, 8 deletions
diff --git a/src/umabot/bot.py b/src/umabot/bot.py index 86e13ee..2519962 100644 --- a/src/umabot/bot.py +++ b/src/umabot/bot.py @@ -70,15 +70,23 @@ class UmaBot: user_agent=config.user_agent ) - # Get subreddit + # Get subreddits self.subreddit = self.reddit.subreddit(config.subreddit_name) + self.all_subreddits = [self.subreddit] + + # Add additional subreddits if configured + if config.additional_subreddits: + additional_names = [name.strip() for name in config.additional_subreddits.split(',')] + for name in additional_names: + if name: + self.all_subreddits.append(self.reddit.subreddit(name)) # Initialize rules self.rules = [ - SpamDetector(config), - UmadditRemovalRule(config), # Remove umaddit references - RoleplayMediaRequiredRule(config), # Require media for roleplay posts - IntelligentRoleplayModerator(config, self.subreddit), # Intelligent roleplay moderation + SpamDetector(config), # Only for okbuddyumamusume + UmadditRemovalRule(config), # For all subreddits + RoleplayMediaRequiredRule(config), # Only for okbuddyumamusume + IntelligentRoleplayModerator(config, self.subreddit), # Only for okbuddyumamusume # RoleplayWordCountRule(config), # Disabled - using intelligent moderator # RoleplayLimiter(config, self.subreddit) # Disabled - using intelligent moderator # StaticRoleplayLimiter(config) # Uncomment to use static roleplay limiting instead @@ -116,8 +124,13 @@ class UmaBot: def _check_new_posts(self): """Check for new posts and apply rules.""" try: - # Get new submissions - new_submissions = list(self.subreddit.new(limit=25)) + # Get new submissions from all subreddits + all_submissions = [] + for subreddit in self.all_subreddits: + new_submissions = list(subreddit.new(limit=25)) + all_submissions.extend(new_submissions) + + new_submissions = all_submissions if not new_submissions: self.logger.debug("No new submissions found") @@ -163,8 +176,17 @@ class UmaBot: self.logger.info(f"Post {submission.id} is already approved, skipping all rules") return - # Apply each rule + # Determine which subreddit this post is from + post_subreddit = submission.subreddit.display_name.lower() + is_okbuddy = post_subreddit == "okbuddyumamusume" + + # Apply each rule based on subreddit for rule in self.rules: + # Skip certain rules for non-okbuddy subreddits + if not is_okbuddy: + if isinstance(rule, (SpamDetector, RoleplayMediaRequiredRule, IntelligentRoleplayModerator)): + continue # Skip these rules for non-okbuddy subreddits + if rule.execute(submission): # If a rule removes the submission, stop applying other rules break diff --git a/src/umabot/config.py b/src/umabot/config.py index 07cb311..164a101 100644 --- a/src/umabot/config.py +++ b/src/umabot/config.py @@ -24,6 +24,7 @@ class Config: # Subreddit configuration subreddit_name: str + additional_subreddits: Optional[str] = "TracenAcademy" # Comma-separated list of additional subreddits # Bot messages roleplay_message: str @@ -57,6 +58,7 @@ class Config: user_agent=os.getenv("REDDIT_USER_AGENT", "UmaBot/0.1.0"), openai_api_key=os.getenv("OPENAI_API_KEY", ""), subreddit_name=os.getenv("SUBREDDIT_NAME", ""), + additional_subreddits=os.getenv("ADDITIONAL_SUBREDDITS", "TracenAcademy"), roleplay_message=os.getenv( "ROLEPLAY_MESSAGE", "Your post has been removed. Only one in-character post is allowed per user." |