From 0c40b105bcd836bc4657d82acc1ca990fa5b81b9 Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Sat, 22 Oct 2022 19:41:13 -0700 Subject: [PATCH] Remove message history limit, add message count report * When fetching the chat history, we don't use the default limit of 100 and set it to unlimited. * For every 1000 messages recorded in the history, we report that in the debug log. Signed-off-by: Alek Ratzloff --- discord_markov/client.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/discord_markov/client.py b/discord_markov/client.py index 42fe656..1e66607 100644 --- a/discord_markov/client.py +++ b/discord_markov/client.py @@ -123,7 +123,7 @@ class Client(discord.Client): ) count = 0 skipped = 0 - async for message in channel.history(after=last_message): + async for message in channel.history(after=last_message, limit=None): if message.author.bot: continue if message.content.strip().startswith("!"): @@ -131,6 +131,15 @@ class Client(discord.Client): continue count += 1 self.chain.add(guild.id, message.author.id, message.content, commit=False) + if count % 1000 == 0: + log.debug( + "%s (%s) %s (%s) - %s messages", + guild.id, + guild.name, + channel.id, + channel.name, + count, + ) self.db.commit() log.info( "Guild %s (%s): channel %s (%s): synchronized %s messages (skipped %s messages that looked like commands)",