From ef02529a4bc4f09cacdac973aef6229eafa20f38 Mon Sep 17 00:00:00 2001 From: agessaman Date: Sun, 7 Sep 2025 10:45:43 -0700 Subject: [PATCH] make @ command work in public channels --- modules/message_handler.py | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/modules/message_handler.py b/modules/message_handler.py index bd19f8f..3204f20 100644 --- a/modules/message_handler.py +++ b/modules/message_handler.py @@ -28,30 +28,6 @@ class MessageHandler: # Time-based cache for recent RF log data self.recent_rf_data = [] - - def get_sender_name_from_pubkey(self, pubkey_prefix: str) -> str: - """ - Look up sender name from pubkey_prefix using contacts. - - Args: - pubkey_prefix: The public key prefix to look up - - Returns: - str: Sender name if found, empty string if not found - """ - if not pubkey_prefix or not hasattr(self.bot.meshcore, 'contacts') or not self.bot.meshcore.contacts: - return "" - - try: - # Look for contact by pubkey prefix - for contact_key, contact_data in self.bot.meshcore.contacts.items(): - if contact_data.get('public_key', '').startswith(pubkey_prefix): - # Return the advertisement name if available, otherwise the contact key - return contact_data.get('adv_name', contact_key) - except Exception as e: - self.logger.debug(f"Error looking up sender name for pubkey_prefix {pubkey_prefix}: {e}") - - return "" # Message correlation system to prevent race conditions self.pending_messages = {} # Store messages waiting for RF data @@ -419,18 +395,9 @@ class MessageHandler: # Format path with comma separation (every 2 characters) path_hex = routing_info['path_hex'] formatted_path = ','.join([path_hex[i:i+2] for i in range(0, len(path_hex), 2)]) - - # Try to get sender name from pubkey_prefix - sender_name = self.get_sender_name_from_pubkey(pubkey_prefix) - sender_info = f" | From: {sender_name}" if sender_name else "" - - self.logger.info(f"🛣️ ROUTING INFO: {routing_info['route_type']} | Path: {formatted_path} ({routing_info['path_length']} bytes) | Type: {routing_info['payload_type']}{sender_info}") + self.logger.info(f"🛣️ ROUTING INFO: {routing_info['route_type']} | Path: {formatted_path} ({routing_info['path_length']} bytes) | Type: {routing_info['payload_type']}") else: - # Try to get sender name from pubkey_prefix - sender_name = self.get_sender_name_from_pubkey(pubkey_prefix) - sender_info = f" | From: {sender_name}" if sender_name else "" - - self.logger.info(f"📡 DIRECT MESSAGE: {routing_info['route_type']} | Type: {routing_info['payload_type']}{sender_info}") + self.logger.info(f"📡 DIRECT MESSAGE: {routing_info['route_type']} | Type: {routing_info['payload_type']}") rf_data = { 'timestamp': current_time,