fresh argument to invalidate cache

This commit is contained in:
Klemek
2021-03-15 13:35:46 +01:00
parent aba2889a63
commit ae8c6d8031
3 changed files with 5 additions and 3 deletions
+2 -1
View File
@@ -38,6 +38,7 @@ class GuildLogs:
target_channels: List[discord.TextChannel] = [],
*,
fast: bool,
fresh: bool,
) -> Tuple[int, int]:
global current_analysis
if self.log_file in current_analysis:
@@ -123,7 +124,7 @@ class GuildLogs:
f"Reading new history...\n0 messages in 0/{max_chan:,} channels\n(this might take a while)",
)
for channel in target_channels:
if channel.id not in self.channels:
if channel.id not in self.channels or fresh:
loading_new += 1
self.channels[channel.id] = ChannelLogs(channel)
start_msg = len(self.channels[channel.id].messages)
+2 -2
View File
@@ -52,7 +52,7 @@ class Scanner(ABC):
elif re.match(r"^<#!?\d+>$", arg):
arg = arg[3:-1] if "!" in arg else arg[2:-1]
if (
arg not in self.valid_args + ["me", "here", "fast"]
arg not in self.valid_args + ["me", "here", "fast", "fresh"]
and (not arg.isdigit() or not self.has_digit_args)
and arg not in str_channel_mentions
and arg not in str_mentions
@@ -93,7 +93,7 @@ class Scanner(ABC):
allowed_mentions=discord.AllowedMentions.none(),
)
total_msg, total_chan = await logs.load(
progress, self.channels, fast="fast" in args
progress, self.channels, fast="fast" in args, fresh="fresh" in args
)
if total_msg == CANCELLED:
await message.channel.send(
+1
View File
@@ -12,6 +12,7 @@ COMMON_HELP_ARGS = (
+ "* @member/me - filter for one or more member\n"
+ "* #channel/here - filter for one or more channel\n"
+ "* fast - only read cache\n"
+ "* fresh - does not read cache (long)\n"
)