mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-05-24 16:25:19 +00:00
feat: Update banned user handling to support prefix matching
- Modified configuration examples to clarify that banned users are now identified by sender names using prefix matching. - Implemented a new method in CommandManager to check if a user is banned based on prefix matching, enhancing the bot's ability to ignore messages from banned senders. - Updated message handling logic to utilize the new prefix matching functionality for improved user management.
This commit is contained in:
@@ -402,6 +402,15 @@ class CommandManager:
|
||||
banned = self.bot.config.get('Banned_Users', 'banned_users', fallback='')
|
||||
return [user.strip() for user in banned.split(',') if user.strip()]
|
||||
|
||||
def is_user_banned(self, sender_id: Optional[str]) -> bool:
|
||||
"""Check if sender is banned using prefix (starts-with) matching.
|
||||
|
||||
A banned entry "Awful Username" matches "Awful Username" and "Awful Username 🍆".
|
||||
"""
|
||||
if not sender_id:
|
||||
return False
|
||||
return any(sender_id.startswith(entry) for entry in self.banned_users)
|
||||
|
||||
def load_monitor_channels(self) -> List[str]:
|
||||
"""Load monitored channels from config"""
|
||||
channels = self.bot.config.get('Channels', 'monitor_channels', fallback='')
|
||||
|
||||
Reference in New Issue
Block a user