blacked
This commit is contained in:
@@ -7,6 +7,7 @@ from utils import mention, from_now, str_datetime, message_link, SPLIT_TOKEN
|
||||
|
||||
MAX_RANDOM_TRIES = 10
|
||||
|
||||
|
||||
class History:
|
||||
def __init__(self):
|
||||
self.messages = []
|
||||
|
||||
@@ -131,8 +131,6 @@ class ChannelLogs:
|
||||
yield len(self.messages), True
|
||||
|
||||
def dict(self) -> dict:
|
||||
channel = serialize(
|
||||
self, not_serialized=["channel", "guild", "start_date"]
|
||||
)
|
||||
channel = serialize(self, not_serialized=["channel", "guild", "start_date"])
|
||||
channel["messages"] = [message.dict() for message in self.messages]
|
||||
return channel
|
||||
|
||||
@@ -83,7 +83,6 @@ class MessageLog:
|
||||
except (discord.NotFound, discord.Forbidden, discord.HTTPException):
|
||||
return None
|
||||
|
||||
|
||||
def dict(self) -> dict:
|
||||
return serialize(
|
||||
self, not_serialized=["channel"], dates=["created_at", "edited_at"]
|
||||
|
||||
@@ -48,7 +48,10 @@ class FindScanner(Scanner):
|
||||
reference=message,
|
||||
)
|
||||
return False
|
||||
self.queries = [(query, query.strip("`") if re.match(r"^`.*`$", query) else None) for query in self.other_args]
|
||||
self.queries = [
|
||||
(query, query.strip("`") if re.match(r"^`.*`$", query) else None)
|
||||
for query in self.other_args
|
||||
]
|
||||
return True
|
||||
|
||||
def compute_message(self, channel: ChannelLogs, message: MessageLog):
|
||||
@@ -125,5 +128,7 @@ class FindScanner(Scanner):
|
||||
if count > 0:
|
||||
matches[message.author].update_use(count, message.created_at)
|
||||
else:
|
||||
matches[query[0]].update_use(count, message.created_at, message.author)
|
||||
matches[query[0]].update_use(
|
||||
count, message.created_at, message.author
|
||||
)
|
||||
return impacted
|
||||
|
||||
@@ -25,7 +25,13 @@ class HistoryScanner(Scanner, ABC):
|
||||
self.all_messages = "all" in args or "everyone" in args
|
||||
self.images_only = "image" in args
|
||||
if not self.images_only:
|
||||
self.queries = [(query.lower(), query.strip("`") if re.match(r"^`.*`$", query) else None) for query in self.other_args]
|
||||
self.queries = [
|
||||
(
|
||||
query.lower(),
|
||||
query.strip("`") if re.match(r"^`.*`$", query) else None,
|
||||
)
|
||||
for query in self.other_args
|
||||
]
|
||||
else:
|
||||
self.queries = []
|
||||
return True
|
||||
|
||||
+17
-3
@@ -30,7 +30,17 @@ from logs import (
|
||||
|
||||
|
||||
class Scanner(ABC):
|
||||
VALID_ARGS = ["me", "here", "fast", "fresh", "mobile", "mention", "nsfw", "nsfw:allow", "nsfw:only"]
|
||||
VALID_ARGS = [
|
||||
"me",
|
||||
"here",
|
||||
"fast",
|
||||
"fresh",
|
||||
"mobile",
|
||||
"mention",
|
||||
"nsfw",
|
||||
"nsfw:allow",
|
||||
"nsfw:only",
|
||||
]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -158,9 +168,13 @@ class Scanner(ABC):
|
||||
|
||||
# filter nsfw channels
|
||||
if self.nsfw == FilterLevel.NONE:
|
||||
self.channels = list(filter(lambda channel:not channel.nsfw, self.channels))
|
||||
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))
|
||||
self.channels = list(
|
||||
filter(lambda channel: channel.nsfw, self.channels)
|
||||
)
|
||||
|
||||
if not await self.init(message, *args):
|
||||
return
|
||||
|
||||
@@ -99,6 +99,7 @@ class FakeMessage:
|
||||
def __init__(self, id: int):
|
||||
self.id = id
|
||||
|
||||
|
||||
# FILE
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user