nsfw filters
This commit is contained in:
+22
-1
@@ -15,6 +15,7 @@ from utils import (
|
||||
RELATIVE_REGEX,
|
||||
parse_time,
|
||||
command_cache,
|
||||
FilterLevel,
|
||||
)
|
||||
from logs import (
|
||||
GuildLogs,
|
||||
@@ -27,7 +28,7 @@ from logs import (
|
||||
|
||||
|
||||
class Scanner(ABC):
|
||||
VALID_ARGS = ["me", "here", "fast", "fresh", "mobile", "mention"]
|
||||
VALID_ARGS = ["me", "here", "fast", "fresh", "mobile", "mention", "nsfw", "nsfw:allow", "nsfw:only"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -139,6 +140,26 @@ class Scanner(ABC):
|
||||
|
||||
self.mention_users = "mention" in args or "mobile" in args
|
||||
|
||||
# nsfw filter
|
||||
if "nsfw" in args or "nsfw:allow" in args:
|
||||
self.nsfw = FilterLevel.ALLOW
|
||||
elif "nsfw:only" in args:
|
||||
self.nsfw = FilterLevel.ONLY
|
||||
else:
|
||||
self.nsfw = FilterLevel.NONE
|
||||
|
||||
# fix nsfw filter if channel specified
|
||||
if not self.full and any(channel.nsfw for channel in self.channels):
|
||||
self.nsfw = FilterLevel.ALLOW
|
||||
elif all(channel.nsfw for channel in self.channels):
|
||||
self.nsfw = FilterLevel.ONLY
|
||||
|
||||
# filter nsfw channels
|
||||
if self.nsfw == FilterLevel.NONE:
|
||||
self.channels = list(filter(lambda channel:not channel.nsfw, self.channels))
|
||||
elif self.nsfw == FilterLevel.ONLY:
|
||||
self.channels = list(filter(lambda channel:channel.nsfw, self.channels))
|
||||
|
||||
if not await self.init(message, *args):
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user