Highrise Bot Auto Launcher Script

#!/usr/bin/env python3
"""
Quick launcher script for the Highrise bot.
This script helps you run the bot with your credentials.
"""

import sys
import subprocess
import os

def main():
    print("πŸ€– Highrise Bot Launcher")
    print("=" * 40)
    
    # Check if the bot file exists
    if not os.path.exists("my_highrise_bot.py"):
        print("❌ Error: my_highrise_bot.py not found!")
        print("Make sure you're in the correct directory.")
        return
    
    # Hardcoded credentials - no need to enter them every time
    room_id = "Your Room Id Here"
    api_token = "Your Bot Api Key"

    print("\nβœ… Using saved credentials:")
    print(f"🏠 Room ID: {room_id}")
    print(f"πŸ”‘ API Token: {api_token[:10]}...")  # Show only first 10 characters for security
    
    # Auto-launch without confirmation (since credentials are hardcoded)
    print(f"\nπŸš€ Auto-launching bot in 2 seconds...")
    import time
    time.sleep(2)  # Brief pause so user can see the credentials
    
    # Run the bot
    try:
        print("\nπŸš€ Starting bot...")
        print("πŸ“ Bot output:")
        print("-" * 40)
        
        # Use subprocess to run the highrise command
        cmd = ["highrise", f"my_highrise_bot:Bot", room_id, api_token]
        subprocess.run(cmd, check=True)
        
    except subprocess.CalledProcessError as e:
        print(f"\n❌ Error running bot: {e}")
        print("\nπŸ”§ Troubleshooting tips:")
        print("1. Make sure you have installed: pip install highrise-bot-sdk==24.1.0")
        print("2. Check your room ID and API token are correct")
        print("3. Ensure you have permissions for the room")
        
    except KeyboardInterrupt:
        print("\n\n⏹️ Bot stopped by user.")
        
    except FileNotFoundError:
        print("\n❌ Error: 'highrise' command not found!")
        print("Please install the SDK first: pip install highrise-bot-sdk==24.1.0")

if __name__ == "__main__":
    main()

Detailed Explanation Of Your Highrise bot Launcher Script :

Header and Description

Python

#!/usr/bin/env python3
"""
Quick launcher script for the Highrise bot.
This script helps you run the bot with your credentials.
"""
  • #!/usr/bin/env python3: This tells the system to use Python 3 to run the script, no matter where Python is installed.

Importing Modules

import sys
import subprocess
import os
  • sys: Provides access to system-level functions (not used here directly but may be useful in future).
  • subprocess: Allows you to run external commands (like launching your bot).
  • os: Helps with file and path operations (e.g., checking if your bot file exists).

Main Function Definition

def main():
  • Defines the main() function that contains the full logic for launching the bot. Python runs this function only when the script is directly executed.

Startup Print

    print("πŸ€– Highrise Bot Launcher")
    print("=" * 40)
  • A simple welcome header. ("=" * 40) prints 40 = signs to separate content visually.

Bot File Check

    if not os.path.exists("my_highrise_bot.py"):
        print("❌ Error: my_highrise_bot.py not found!")
        print("Make sure you're in the correct directory.")
        return
  • Checks whether the my_highrise_bot.py file exists in the same folder.
  • If it’s missing, it prints an error and stops the script early using return.

Hardcoded Credentials

    room_id = "Your Room Id"
    api_token = "Your Bot Api Key"
  • These are your pre-set Highrise room ID and API token, so you don’t have to enter them every time.

Credential Display

    print("\nβœ… Using saved credentials:")
    print(f"🏠 Room ID: {room_id}")
    print(f"πŸ”‘ API Token: {api_token[:10]}...")
  • This prints the room ID and only the first 10 characters of the token (for privacy).
  • Shows the user which credentials are being used.

Pause Before Launch

    print(f"\nπŸš€ Auto-launching bot in 2 seconds...")
    import time
    time.sleep(2)
  • Adds a 2-second delay to give the user a moment to review the credentials before launching.
  • import time is done here locally (can also be imported at the top).

Try to Run the Bot

    try:
        print("\nπŸš€ Starting bot...")
        print("πŸ“ Bot output:")
        print("-" * 40)
  • A try block is used to catch any errors that occur while launching the bot.
  • Displays some visual output before running the actual bot command.

Run Highrise Bot Using Subprocess

        cmd = ["highrise", f"my_highrise_bot:Bot", room_id, api_token]
        subprocess.run(cmd, check=True)
  • Constructs a command list: highrise my_highrise_bot:Bot <room_id> <api_token>.
  • subprocess.run(..., check=True) executes the command and raises an error if it fails.

Handle Errors Gracefully

    except subprocess.CalledProcessError as e:
        print(f"\n❌ Error running bot: {e}")
        print("\nπŸ”§ Troubleshooting tips:")
        print("1. Make sure you have installed: pip install highrise-bot-sdk==24.1.0")
        print("2. Check your room ID and API token are correct")
        print("3. Ensure you have permissions for the room")
  • Catches errors from the bot command (like wrong token, room ID, or no SDK installed).
  • Suggests common fixes.

Handle Keyboard Interrupt (Ctrl+C)

    except KeyboardInterrupt:
        print("\n\n⏹️ Bot stopped by user.")
  • If the user manually stops the bot using Ctrl+C, this message is printed instead of a crash.

Handle Missing Command

    except FileNotFoundError:
        print("\n❌ Error: 'highrise' command not found!")
        print("Please install the SDK first: pip install highrise-bot-sdk==24.1.0")
  • This catches the case where the highrise CLI tool is not installed and gives a direct fix.

Run the Main Function

if __name__ == "__main__":
    main()
  • This makes sure the main() function runs only if this script is executed directly (not imported as a module somewhere else).

Summary :

This script is a convenient auto-launcher for your Highrise bot. It:

  • Checks for the bot file
  • Uses hardcoded credentials for instant launch
  • Runs the bot using the highrise CLI
  • Handles missing files, bad credentials, and user interrupts gracefully
  • Waits for 2 seconds before launch so you can confirm the details

Soon Posting Complete Room Bot Script & How to make your own music bot…