#!/usr/bin/env python3 """ Test script for Read2Burn mailbox functionality """ import sys import os # Add the src directory to Python path sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) def test_read2burn(): try: from src.addons.read2burn_addon import read2burn_service print("๐Ÿงช Testing Read2Burn Mailbox...") # Test player ID player_id = "test_player_123" print("\n๐Ÿ“ Testing Message Creation...") # Test creating messages result1 = read2burn_service.handle_command(player_id, "create This is a secret message!") print(f"๐Ÿ“ค Create command result: {result1}") result2 = read2burn_service.handle_command(player_id, "create Another confidential note") print(f"๐Ÿ“ค Create command result: {result2}") print("\n๐Ÿ“‹ Testing Message Listing...") # Test listing messages list_result = read2burn_service.handle_command(player_id, "list") print(f"๐Ÿ“œ List command result: {list_result}") print("\n๐Ÿ“– Testing Message Reading...") # Extract message ID from first create result to test reading import re match = re.search(r'Message ID:\*\* `([^`]+)`', result1) if match: message_id = match.group(1) print(f"๐Ÿ” Found message ID: {message_id}") # Test reading the message read_result = read2burn_service.handle_command(player_id, f"read {message_id}") print(f"๐Ÿ“– Read command result: {read_result}") # Try to read again (should be burned) read_again = read2burn_service.handle_command(player_id, f"read {message_id}") print(f"๐Ÿ”ฅ Read again result: {read_again}") print("\nโ“ Testing Help Command...") help_result = read2burn_service.handle_command(player_id, "help") print(f"๐Ÿ’ก Help command result: {help_result}") print("\n๐Ÿ“Š Testing Message History...") history = read2burn_service.get_player_message_history(player_id) print(f"๐Ÿ“ˆ Message history: {len(history)} entries") for entry in history: print(f" - {entry}") print("\nโœ… Read2Burn test completed successfully!") except Exception as e: print(f"โŒ Test failed: {e}") import traceback traceback.print_exc() if __name__ == "__main__": test_read2burn()