mirror of
https://github.com/MODSetter/SurfSense.git
synced 2025-09-01 18:19:08 +00:00
feat: removed limit on message fetching
This commit is contained in:
parent
59523563be
commit
d11b636113
2 changed files with 3 additions and 6 deletions
|
@ -142,7 +142,6 @@ class DiscordConnector(commands.Bot):
|
|||
async def get_channel_history(
|
||||
self,
|
||||
channel_id: str,
|
||||
limit: int = 100,
|
||||
start_date: str = None,
|
||||
end_date: str = None,
|
||||
) -> list[dict]:
|
||||
|
@ -151,7 +150,6 @@ class DiscordConnector(commands.Bot):
|
|||
|
||||
Args:
|
||||
channel_id (str): The ID of the channel to fetch messages from.
|
||||
limit (int): Maximum number of messages to fetch.
|
||||
start_date (str): Optional start date in ISO format (YYYY-MM-DD).
|
||||
end_date (str): Optional end date in ISO format (YYYY-MM-DD).
|
||||
|
||||
|
@ -188,13 +186,13 @@ class DiscordConnector(commands.Bot):
|
|||
|
||||
if end_date:
|
||||
try:
|
||||
end_datetime = datetime.datetime.fromisoformat(f"{end_date}T23:59:59.999999").replace(tzinfo=datetime.timezone.utc)
|
||||
end_datetime = datetime.datetime.fromisoformat(f"{end_date}").replace(tzinfo=datetime.timezone.utc)
|
||||
before = end_datetime
|
||||
except ValueError:
|
||||
logger.warning(f"Invalid end_date format: {end_date}. Ignoring.")
|
||||
|
||||
try:
|
||||
async for message in channel.history(limit=limit, before=before, after=after):
|
||||
async for message in channel.history(limit=None, before=before, after=after):
|
||||
messages_data.append(
|
||||
{
|
||||
"id": str(message.id),
|
||||
|
|
|
@ -993,7 +993,7 @@ async def index_discord_messages(
|
|||
return 0, f"Failed to get Discord guilds: {str(e)}"
|
||||
if not guilds:
|
||||
logger.info("No Discord guilds found to index")
|
||||
|
||||
|
||||
await discord_client.close_bot()
|
||||
return 0, "No Discord guilds found"
|
||||
|
||||
|
@ -1020,7 +1020,6 @@ async def index_discord_messages(
|
|||
channel_id=channel_id,
|
||||
start_date=start_date_str,
|
||||
end_date=end_date_str,
|
||||
limit=1000
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to get messages for channel {channel_name}: {str(e)}")
|
||||
|
|
Loading…
Add table
Reference in a new issue