#!/bin/bash
# Script to test if the Keet bot can connect with a real identity
# Set the storage directory
STORAGE_DIR="test-keet-storage"
# Test room key (replace with a valid room key for testing)
TEST_ROOM_KEY="pear://keet/test123"
# Update identity files to ensure a real identity
echo "Updating identity files to ensure real identity..."
node tests/update_real_keet_identity.js --storage="$STORAGE_DIR" --name="KeetBot"
# Check if the identity files were updated successfully
if [ $? -ne 0 ]; then
echo "Failed to update identity files"
exit 1
fi
# Check if the main identity file exists and has anonymous=false
if [ ! -f "$STORAGE_DIR/identity.json" ]; then
echo "Main identity file not found"
exit 1
fi
# Check if the database identity file exists and has anonymous=false
if [ ! -f "$STORAGE_DIR/db/identity.json" ]; then
echo "Database identity file not found"
exit 1
fi
echo "Identity files updated successfully"
echo "Main identity file: $STORAGE_DIR/identity.json"
echo "Database identity file: $STORAGE_DIR/db/identity.json"
# Display the identity files
echo "Main identity file content:"
cat "$STORAGE_DIR/identity.json"
echo ""
echo "Database identity file content:"
cat "$STORAGE_DIR/db/identity.json"
echo ""
# Note about the modified keet_cmd.js script
echo "Note: The keet_cmd.js script has been modified to ensure anonymous=false in the identity"
echo "This ensures that the identity is properly recognized as a real identity by the Keet client"
echo ""
# Ask the user if they want to test the connection
read -p "Do you want to test the connection with a real room key? (y/n): " answer
if [ "$answer" != "y" ]; then
echo "Test skipped"
exit 0
fi
# Ask for a real room key
read -p "Enter a real room key (e.g., pear://keet/abcdef123456): " room_key
if [ -z "$room_key" ]; then
echo "No room key provided, using test room key: $TEST_ROOM_KEY"
room_key="$TEST_ROOM_KEY"
fi
# Run the Keet bot with the provided room key
echo "Starting Keet bot with room key: $room_key"
echo "Press Ctrl+C to stop the bot"
node tests/keet_cmd.js --room-key="$room_key" --storage="$STORAGE_DIR" --name="KeetBot" --verbose