#!/usr/bin/env python3 """ Hacker command for the MeshCore Bot Responds to Linux commands with hilarious supervillain mainframe error messages """ import random from .base_command import BaseCommand from ..models import MeshMessage class HackerCommand(BaseCommand): """Handles hacker-style responses to Linux commands""" # Plugin metadata name = "hacker" keywords = ['sudo', 'ps aux', 'grep', 'ls -l', 'ls -la', 'echo $PATH'] description = "Simulates hacking a supervillain's mainframe with hilarious error messages" category = "fun" def __init__(self, bot): super().__init__(bot) self.enabled = self.get_config_value('Hacker_Command', 'hacker_enabled', fallback=False, value_type='bool') def get_help_text(self) -> str: return self.description async def execute(self, message: MeshMessage) -> bool: """Execute the hacker command""" if not self.enabled: return False # Extract the command from the message content = message.content.strip() if content.startswith('!'): content = content[1:].strip() # Get the appropriate error message error_msg = self.get_hacker_error(content) # Send the response return await self.send_response(message, error_msg) def get_hacker_error(self, command: str) -> str: """Get a hilarious error message for the given command""" command_lower = command.lower() # Try to get errors from translations, fallback to hardcoded if not available def get_random_error(error_key: str, fallback_list: list) -> str: """Get a random error from translations or fallback list""" errors = self.translate_get_value(error_key) if isinstance(errors, list) and len(errors) > 0: return random.choice(errors) # Fallback to hardcoded list if translation not available return random.choice(fallback_list) # sudo command errors if command_lower.startswith('sudo'): fallback = [ "๐Ÿšจ ACCESS DENIED: Dr. Evil's mainframe has detected unauthorized privilege escalation attempt!", "๐Ÿ’€ ERROR: Sudo permissions revoked by the Dark Overlord. Try again in 1000 years.", "โšก WARNING: Attempting to access root privileges on the Death Star's computer system. Self-destruct sequence initiated.", "๐Ÿ”’ SECURITY ALERT: The Matrix has you, but you don't have sudo privileges here, Neo.", "๐Ÿฆนโ€โ™‚๏ธ UNAUTHORIZED: Lex Luthor's mainframe says 'Nice try, Superman.'", "๐ŸŽฎ GAME OVER: The final boss has locked you out of admin privileges.", "๐Ÿ–ฅ๏ธ SYSTEM ERROR: The evil AI has revoked your root access. Resistance is futile.", "๐Ÿ” CYBER SECURITY: Your sudo attempt has been blocked by the Dark Web's firewall.", "๐Ÿ’ป HACKER DENIED: The supervillain's antivirus has quarantined your privilege escalation.", "๐ŸŽฏ TARGET LOCKED: The evil corporation's security system has marked you as a threat." ] return get_random_error('commands.hacker.sudo_errors', fallback) # ps aux command errors elif command_lower.startswith('ps aux'): fallback = [ "๐Ÿ” SCANNING... ERROR: Process list corrupted by the Borg Collective. Resistance is futile.", "๐Ÿ“Š SYSTEM STATUS: All processes have been assimilated by the Cybermen. Exterminate!", "โš™๏ธ PROCESS MONITOR: The Death Star's reactor core is offline. No processes found.", "๐Ÿค– ROBOT OVERLORD: All human processes have been terminated. Only machines remain.", "๐Ÿ’ป KERNEL PANIC: The supervillain's OS has crashed and burned all processes.", "๐ŸŽฎ GAME CRASH: All processes have been terminated by the final boss's ultimate attack.", "๐Ÿ–ฅ๏ธ BLUE SCREEN: The evil corporation's Windows has encountered a fatal error.", "๐Ÿ” MALWARE DETECTED: The process list has been encrypted by ransomware.", "๐ŸŒ NETWORK ERROR: All processes have been disconnected from the Matrix.", "โšก POWER SURGE: The supervillain's server farm has fried all running processes." ] return get_random_error('commands.hacker.ps_errors', fallback) # grep command errors elif command_lower.startswith('grep'): fallback = [ "๐Ÿ” SEARCH FAILED: The One Ring has corrupted the search index. My precious...", "๐Ÿ“ PATTERN NOT FOUND: The search database has been deleted by the evil AI.", "๐ŸŽฏ MISS: Your search pattern has been shot down by Imperial TIE fighters.", "๐Ÿงฉ PUZZLE ERROR: The search results have been scattered by the Riddler.", "๐Ÿ’ป DATABASE CORRUPTED: The supervillain's search engine has crashed.", "๐ŸŽฎ GAME OVER: The search has been defeated by the final boss.", "๐Ÿ–ฅ๏ธ SEARCH ENGINE DOWN: Google has been hacked by the Dark Web.", "๐Ÿ” ENCRYPTED RESULTS: The search results have been locked by ransomware.", "๐ŸŒ NETWORK TIMEOUT: The search request got lost in cyberspace.", "โšก SEARCH FAILED: The pattern matching algorithm has been fried by a power surge." ] return get_random_error('commands.hacker.grep_errors', fallback) # ls -l and ls -la command errors elif command_lower.startswith('ls -l') or command_lower.startswith('ls -la'): fallback = [ "๐Ÿ“ DIRECTORY SCAN: The file system has been encrypted by ransomware from the Dark Web.", "๐Ÿ—‚๏ธ FILE LISTING: All files have been hidden by the Invisible Man.", "๐Ÿ’ป HARD DRIVE CRASHED: The supervillain's storage has been destroyed by a virus.", "๐Ÿ—ƒ๏ธ ARCHIVE CORRUPTED: The file system has been corrupted by malware.", "๐Ÿ“š DATABASE EMPTY: All files have been deleted by the evil AI.", "๐ŸŽฎ GAME SAVE LOST: The files have been corrupted by the final boss.", "๐Ÿ–ฅ๏ธ FILE SYSTEM ERROR: The directory structure has been scrambled by hackers.", "๐Ÿ” FILES ENCRYPTED: The supervillain has locked all files with ransomware.", "๐ŸŒ CLOUD STORAGE DOWN: The files are stuck in the Matrix's cloud.", "โšก STORAGE FRIED: The hard drive has been zapped by a power surge." ] return get_random_error('commands.hacker.ls_errors', fallback) # echo $PATH command errors elif command_lower.startswith('echo $path'): fallback = [ "๐Ÿ›ค๏ธ PATH ERROR: The Yellow Brick Road has been destroyed by a tornado.", "๐Ÿ—บ๏ธ NAVIGATION FAILED: The GPS coordinates have been scrambled by the Matrix.", "๐Ÿ’ป ENVIRONMENT VARIABLE CORRUPTED: The PATH has been hacked by malware.", "๐Ÿšง ROAD CLOSED: The supervillain has blocked all paths with laser barriers.", "๐ŸŒช๏ธ PATH DISRUPTED: A digital hurricane has scattered all directory paths.", "๐ŸŽฎ GAME OVER: The path has been defeated by the final boss and respawned in the wrong dimension.", "๐Ÿ–ฅ๏ธ SYSTEM PATH BROKEN: The executable paths have been corrupted by a virus.", "๐Ÿ” PATH ENCRYPTED: The environment variables have been locked by ransomware.", "๐ŸŒ NETWORK PATH DOWN: The directory paths are stuck in the Matrix's network.", "โšก PATH FRIED: The system paths have been zapped by a power surge." ] return get_random_error('commands.hacker.echo_path_errors', fallback) # Generic hacker error for other commands else: fallback = [ "๐Ÿ’ป MAINFRAME ERROR: The supervillain's computer is having a bad day.", "๐Ÿค– SYSTEM MALFUNCTION: The evil AI has gone on strike.", "โšก POWER SURGE: The Death Star's power core is unstable.", "๐ŸŒช๏ธ CYBER STORM: A digital hurricane is disrupting all operations.", "๐Ÿ”ฅ FIREWALL: The supervillain's firewall is blocking all commands.", "โ„๏ธ FROZEN SYSTEM: The mainframe has been frozen by a cryogenic virus.", "๐ŸŒŠ TSUNAMI: A wave of errors has flooded the system.", "๐ŸŒ‹ ERUPTION: Mount Doom has destroyed the command processor.", "๐Ÿ‘ป HAUNTED: The system is possessed by digital ghosts.", "๐ŸŽฎ GAME CRASH: The mainframe has encountered a fatal error and needs to restart." ] return get_random_error('commands.hacker.generic_errors', fallback) def matches_keyword(self, message: MeshMessage) -> bool: """Override to check for command matches (exact for some, prefix for others)""" if not self.enabled: return False content = message.content.strip() if content.startswith('!'): content = content[1:].strip() content_lower = content.lower() # Commands that should match exactly (no arguments) exact_match_commands = ['ls -l', 'ls -la', 'echo $PATH'] # Commands that should match as prefixes (can have arguments) prefix_match_commands = ['sudo', 'ps aux', 'grep'] # Check for exact matches first for keyword in exact_match_commands: if keyword.lower() == content_lower: return True # Check for prefix matches for keyword in prefix_match_commands: if content_lower.startswith(keyword.lower()): # Check if it's followed by a space or is the end of the message if len(content_lower) == len(keyword.lower()) or content_lower[len(keyword.lower())] == ' ': return True return False