overload security
This commit is contained in:
@@ -69,6 +69,11 @@ async def compute(client: discord.client, message: discord.Message, *args: str):
|
|||||||
async with message.channel.typing():
|
async with message.channel.typing():
|
||||||
progress = await message.channel.send("```Starting analysis...```")
|
progress = await message.channel.send("```Starting analysis...```")
|
||||||
total_msg, total_chan = await logs.load(progress, channels)
|
total_msg, total_chan = await logs.load(progress, channels)
|
||||||
|
if total_msg == -1:
|
||||||
|
await message.channel.send(
|
||||||
|
"f{message.author} An analysis is already running on this server, please be patient."
|
||||||
|
)
|
||||||
|
else:
|
||||||
msg_count = 0
|
msg_count = 0
|
||||||
chan_count = 0
|
chan_count = 0
|
||||||
for id in logs.channels:
|
for id in logs.channels:
|
||||||
|
|||||||
+7
-1
@@ -15,6 +15,8 @@ if not os.path.exists(LOG_DIR):
|
|||||||
CHUNK_SIZE = 1000
|
CHUNK_SIZE = 1000
|
||||||
FORMAT = 2
|
FORMAT = 2
|
||||||
|
|
||||||
|
current_analysis = []
|
||||||
|
|
||||||
|
|
||||||
class FakeMessage:
|
class FakeMessage:
|
||||||
def __init__(self, id: int):
|
def __init__(self, id: int):
|
||||||
@@ -151,7 +153,10 @@ class GuildLogs:
|
|||||||
|
|
||||||
async def load(
|
async def load(
|
||||||
self, progress: discord.Message, target_channels: List[discord.TextChannel] = []
|
self, progress: discord.Message, target_channels: List[discord.TextChannel] = []
|
||||||
):
|
) -> Tuple[int, int]:
|
||||||
|
if self.log_file in current_analysis:
|
||||||
|
return -1, -1
|
||||||
|
current_analysis += [self.log_file]
|
||||||
await progress.edit(
|
await progress.edit(
|
||||||
content=f"```Reading history...\n(this might take a while)```"
|
content=f"```Reading history...\n(this might take a while)```"
|
||||||
)
|
)
|
||||||
@@ -220,4 +225,5 @@ class GuildLogs:
|
|||||||
await progress.edit(
|
await progress.edit(
|
||||||
content=f"```Analysing...\n{total_msg} messages in {total_chan} channels```"
|
content=f"```Analysing...\n{total_msg} messages in {total_chan} channels```"
|
||||||
)
|
)
|
||||||
|
current_analysis.remove(self.log_file)
|
||||||
return total_msg, total_chan
|
return total_msg, total_chan
|
||||||
|
|||||||
Reference in New Issue
Block a user