feat: Improve daily recap functionality

- Changed the daily recap time to 22:00.
- Modified the `send_daily_recap` function to split the recap message into multiple messages if it exceeds 2000 characters to avoid hitting the Discord message length limit.
- Added a 1-second delay between each message chunk to avoid rate limiting.
This commit is contained in:
2025-09-15 13:27:40 -05:00
parent e559e16e35
commit e64b880c97
4 changed files with 21 additions and 12 deletions

View File

@@ -455,18 +455,26 @@ def send_daily_recap():
"""Sends a daily recap of events to Discord."""
global daily_events
if daily_events:
recap_message = "\n".join(daily_events)
webhook = DiscordWebhook(url=config.DISCORD_WEBHOOK_URL, content=f"**Daily Recap:**\n{recap_message}")
try:
response = webhook.execute()
if response.status_code == 200:
logger.info("Daily recap sent successfully.")
else:
logger.error(f"Error sending daily recap: {response.status_code} - {response.content}")
except Exception as e:
logger.error(f"Error sending daily recap: {e}")
recap_message = "**Daily Recap:**\n" + "\n".join(daily_events)
# Split the message into chunks of 2000 characters
message_chunks = [recap_message[i:i+2000] for i in range(0, len(recap_message), 2000)]
for chunk in message_chunks:
webhook = DiscordWebhook(url=config.DISCORD_WEBHOOK_URL, content=chunk)
try:
response = webhook.execute()
if response.status_code == 200:
logger.info("Daily recap chunk sent successfully.")
else:
logger.error(f"Error sending daily recap chunk: {response.status_code} - {response.content}")
except Exception as e:
logger.error(f"Error sending daily recap chunk: {e}")
time.sleep(1) # Wait 1 second between chunks to avoid rate limiting
daily_events = [] # Reset for the next day
def run_monitoring_cycle(nmap_scan_counter):
"""Runs a single monitoring cycle."""