Now with sawato life chat

This commit is contained in:
erik 2025-06-25 08:50:08 +00:00
parent 7ff94b59a8
commit 00ef1d1f4b
2 changed files with 31 additions and 13 deletions

View file

@ -38,6 +38,7 @@ SHARED_SECRET = 'your_shared_secret'
ACLOG_CHANNEL_ID = int(os.getenv('ACLOG_CHANNEL_ID', '1349649482786275328')) ACLOG_CHANNEL_ID = int(os.getenv('ACLOG_CHANNEL_ID', '1349649482786275328'))
COMMON_RARE_CHANNEL_ID = int(os.getenv('COMMON_RARE_CHANNEL_ID', '1355328792184226014')) COMMON_RARE_CHANNEL_ID = int(os.getenv('COMMON_RARE_CHANNEL_ID', '1355328792184226014'))
GREAT_RARE_CHANNEL_ID = int(os.getenv('GREAT_RARE_CHANNEL_ID', '1353676584334131211')) 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 # Character to monitor for allegiance chat
MONITOR_CHARACTER = os.getenv('MONITOR_CHARACTER', 'Dunking Rares') MONITOR_CHARACTER = os.getenv('MONITOR_CHARACTER', 'Dunking Rares')
@ -94,10 +95,12 @@ class DiscordRareMonitor:
aclog_channel = self.client.get_channel(ACLOG_CHANNEL_ID) aclog_channel = self.client.get_channel(ACLOG_CHANNEL_ID)
common_channel = self.client.get_channel(COMMON_RARE_CHANNEL_ID) common_channel = self.client.get_channel(COMMON_RARE_CHANNEL_ID)
great_channel = self.client.get_channel(GREAT_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 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 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 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: if aclog_channel:
logger.info(f"📍 AC Log channel: #{aclog_channel.name}") logger.info(f"📍 AC Log channel: #{aclog_channel.name}")
@ -658,7 +661,7 @@ class DiscordRareMonitor:
logger.error(f"❌ Error posting to Discord: {e}") logger.error(f"❌ Error posting to Discord: {e}")
async def post_chat_to_discord(self, data: dict): 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: try:
character_name = data.get('character_name', 'Unknown Character') character_name = data.get('character_name', 'Unknown Character')
chat_text = data.get('text', '') chat_text = data.get('text', '')
@ -680,32 +683,32 @@ class DiscordRareMonitor:
time_str = timestamp.strftime("%H:%M:%S") time_str = timestamp.strftime("%H:%M:%S")
message_content = f"`{time_str}` **{character_name}**: {chat_text}" message_content = f"`{time_str}` **{character_name}**: {chat_text}"
# Get AC Log channel # Get sawatolife channel
channel = self.client.get_channel(ACLOG_CHANNEL_ID) channel = self.client.get_channel(SAWATOLIFE_CHANNEL_ID)
if channel: if channel:
await channel.send(message_content) await channel.send(message_content)
logger.debug(f"📤 Posted chat to #{channel.name}: {character_name}") logger.debug(f"📤 Posted chat to #{channel.name}: {character_name}")
else: 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: except Exception as e:
logger.error(f"❌ Error posting chat to Discord: {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): 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: try:
# Create debug message showing classification # Create debug message showing classification
debug_message = f"🔍 **RARE DEBUG**: `{rare_name}` → **{rare_type.upper()}** (found by {character_name})" debug_message = f"🔍 **RARE DEBUG**: `{rare_name}` → **{rare_type.upper()}** (found by {character_name})"
# Get AC Log channel # Get sawatolife channel
channel = self.client.get_channel(ACLOG_CHANNEL_ID) channel = self.client.get_channel(SAWATOLIFE_CHANNEL_ID)
if channel: if channel:
await channel.send(debug_message) await channel.send(debug_message)
logger.debug(f"📤 Posted rare debug to #{channel.name}: {rare_name} -> {rare_type}") logger.debug(f"📤 Posted rare debug to #{channel.name}: {rare_name} -> {rare_type}")
else: 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: except Exception as e:
logger.error(f"❌ Error posting rare debug to Discord: {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}") logger.error(f"❌ Error posting vortex warning to Discord: {e}")
async def post_status_to_aclog(self, status_message: str): async def post_status_to_aclog(self, status_message: str):
"""Post status update to AC Log channel.""" """Post status update to sawatolife channel."""
try: try:
# Create status message with timestamp # Create status message with timestamp
timestamp = datetime.now().strftime("%H:%M:%S") timestamp = datetime.now().strftime("%H:%M:%S")
message = f"`{timestamp}` **BOT STATUS**: {status_message}" message = f"`{timestamp}` **BOT STATUS**: {status_message}"
# Get AC Log channel # Get sawatolife channel
channel = self.client.get_channel(ACLOG_CHANNEL_ID) channel = self.client.get_channel(SAWATOLIFE_CHANNEL_ID)
if channel: if channel:
await channel.send(message) await channel.send(message)
logger.debug(f"📤 Posted status to #{channel.name}: {status_message}") logger.debug(f"📤 Posted status to #{channel.name}: {status_message}")
else: 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: except Exception as e:
logger.error(f"❌ Error posting status to Discord: {e}") logger.error(f"❌ Error posting status to Discord: {e}")

17
main.py
View file

@ -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}") logger.info(f"New portal discovered: {portal_name} at {ns_rounded}, {ew_rounded} by {character_name}")
else: 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 # Broadcast to browser clients for map updates
await _broadcast_to_browser_clients(data) await _broadcast_to_browser_clients(data)