From 00ef1d1f4b6f1c4221ebdb4db4883e8623f78c3a Mon Sep 17 00:00:00 2001 From: erik Date: Wed, 25 Jun 2025 08:50:08 +0000 Subject: [PATCH] Now with sawato life chat --- discord-rare-monitor/discord_rare_monitor.py | 27 +++++++++++--------- main.py | 17 +++++++++++- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/discord-rare-monitor/discord_rare_monitor.py b/discord-rare-monitor/discord_rare_monitor.py index a5797ac7..c314f31a 100644 --- a/discord-rare-monitor/discord_rare_monitor.py +++ b/discord-rare-monitor/discord_rare_monitor.py @@ -38,6 +38,7 @@ SHARED_SECRET = 'your_shared_secret' ACLOG_CHANNEL_ID = int(os.getenv('ACLOG_CHANNEL_ID', '1349649482786275328')) COMMON_RARE_CHANNEL_ID = int(os.getenv('COMMON_RARE_CHANNEL_ID', '1355328792184226014')) GREAT_RARE_CHANNEL_ID = int(os.getenv('GREAT_RARE_CHANNEL_ID', '1353676584334131211')) +SAWATOLIFE_CHANNEL_ID = int(os.getenv('SAWATOLIFE_CHANNEL_ID', '1387323032271327423')) # Character to monitor for allegiance chat MONITOR_CHARACTER = os.getenv('MONITOR_CHARACTER', 'Dunking Rares') @@ -94,10 +95,12 @@ class DiscordRareMonitor: aclog_channel = self.client.get_channel(ACLOG_CHANNEL_ID) common_channel = self.client.get_channel(COMMON_RARE_CHANNEL_ID) great_channel = self.client.get_channel(GREAT_RARE_CHANNEL_ID) + sawatolife_channel = self.client.get_channel(SAWATOLIFE_CHANNEL_ID) logger.info(f"🔍 Looking for aclog channel {ACLOG_CHANNEL_ID}: {'Found' if aclog_channel else 'NOT FOUND'}") logger.info(f"🔍 Looking for common channel {COMMON_RARE_CHANNEL_ID}: {'Found' if common_channel else 'NOT FOUND'}") logger.info(f"🔍 Looking for great channel {GREAT_RARE_CHANNEL_ID}: {'Found' if great_channel else 'NOT FOUND'}") + logger.info(f"🔍 Looking for sawatolife channel {SAWATOLIFE_CHANNEL_ID}: {'Found' if sawatolife_channel else 'NOT FOUND'}") if aclog_channel: logger.info(f"📍 AC Log channel: #{aclog_channel.name}") @@ -658,7 +661,7 @@ class DiscordRareMonitor: logger.error(f"❌ Error posting to Discord: {e}") async def post_chat_to_discord(self, data: dict): - """Post chat message to AC Log Discord channel.""" + """Post chat message to sawatolife Discord channel.""" try: character_name = data.get('character_name', 'Unknown Character') chat_text = data.get('text', '') @@ -680,32 +683,32 @@ class DiscordRareMonitor: time_str = timestamp.strftime("%H:%M:%S") message_content = f"`{time_str}` **{character_name}**: {chat_text}" - # Get AC Log channel - channel = self.client.get_channel(ACLOG_CHANNEL_ID) + # Get sawatolife channel + channel = self.client.get_channel(SAWATOLIFE_CHANNEL_ID) if channel: await channel.send(message_content) logger.debug(f"📤 Posted chat to #{channel.name}: {character_name}") else: - logger.error(f"❌ Could not find AC Log channel ID: {ACLOG_CHANNEL_ID}") + logger.error(f"❌ Could not find sawatolife channel ID: {SAWATOLIFE_CHANNEL_ID}") except Exception as e: logger.error(f"❌ Error posting chat to Discord: {e}") async def post_rare_debug_to_aclog(self, rare_name: str, rare_type: str, character_name: str): - """Post rare classification debug info to AC Log channel.""" + """Post rare classification debug info to sawatolife channel.""" try: # Create debug message showing classification debug_message = f"🔍 **RARE DEBUG**: `{rare_name}` → **{rare_type.upper()}** (found by {character_name})" - # Get AC Log channel - channel = self.client.get_channel(ACLOG_CHANNEL_ID) + # Get sawatolife channel + channel = self.client.get_channel(SAWATOLIFE_CHANNEL_ID) if channel: await channel.send(debug_message) logger.debug(f"📤 Posted rare debug to #{channel.name}: {rare_name} -> {rare_type}") else: - logger.error(f"❌ Could not find AC Log channel for debug: {ACLOG_CHANNEL_ID}") + logger.error(f"❌ Could not find sawatolife channel for debug: {SAWATOLIFE_CHANNEL_ID}") except Exception as e: logger.error(f"❌ Error posting rare debug to Discord: {e}") @@ -774,20 +777,20 @@ class DiscordRareMonitor: logger.error(f"❌ Error posting vortex warning to Discord: {e}") async def post_status_to_aclog(self, status_message: str): - """Post status update to AC Log channel.""" + """Post status update to sawatolife channel.""" try: # Create status message with timestamp timestamp = datetime.now().strftime("%H:%M:%S") message = f"`{timestamp}` **BOT STATUS**: {status_message}" - # Get AC Log channel - channel = self.client.get_channel(ACLOG_CHANNEL_ID) + # Get sawatolife channel + channel = self.client.get_channel(SAWATOLIFE_CHANNEL_ID) if channel: await channel.send(message) logger.debug(f"📤 Posted status to #{channel.name}: {status_message}") else: - logger.error(f"❌ Could not find AC Log channel for status: {ACLOG_CHANNEL_ID}") + logger.error(f"❌ Could not find sawatolife channel for status: {SAWATOLIFE_CHANNEL_ID}") except Exception as e: logger.error(f"❌ Error posting status to Discord: {e}") diff --git a/main.py b/main.py index 99411d25..31309e0b 100644 --- a/main.py +++ b/main.py @@ -2017,7 +2017,22 @@ async def ws_receive_snapshots( ) logger.info(f"New portal discovered: {portal_name} at {ns_rounded}, {ew_rounded} by {character_name}") else: - logger.debug(f"Portal already exists at {ns_rounded}, {ew_rounded}") + # Update timestamp for existing portal to keep it alive + await database.execute( + """ + UPDATE portals + SET discovered_at = :timestamp, discovered_by = :character_name + WHERE ROUND(ns::numeric, 2) = :ns_rounded + AND ROUND(ew::numeric, 2) = :ew_rounded + """, + { + "timestamp": timestamp, + "character_name": character_name, + "ns_rounded": ns_rounded, + "ew_rounded": ew_rounded + } + ) + logger.info(f"Portal timestamp updated: {portal_name} at {ns_rounded}, {ew_rounded} by {character_name}") # Broadcast to browser clients for map updates await _broadcast_to_browser_clients(data)