z060142 bb1753796b commit message:
Refactor keyword detection with dual-template matching and coordinate correction

- Overhauled `find_keyword_in_region` in `DetectionModule` to act as a wrapper for a new dual-method detection system.
- Introduced `find_keyword_dual_method`, now the default detection method (enabled via `use_dual_method=True`):
  - Performs template matching (`cv2.matchTemplate`) on both grayscale and CLAHE-enhanced versions of screenshots and templates.
  - Handles inverted images (`cv2.bitwise_not`) for robustness under dark/light themes.
  - Coordinates returned by matching are corrected from relative region space to absolute screen coordinates to match `pyautogui`.
  - Combines matching results using a tiered fallback system:
    1. Prefer overlapping results from both methods within a pixel threshold.
    2. Fallback to high-confidence single-method results.
- Maintains `_find_keyword_legacy` for backward compatibility using `pyautogui.locateAllOnScreen`.
- Simplified keyword template set to focus on three core types: `keyword_wolf_lower`, `keyword_Wolf_upper`, and `keyword_wolf_reply`.
- Integrated runtime performance tracking via counters and `print_detection_stats()` for debugging and optimization.
- Adds debug visualization at `DEBUG_LEVEL >= 3` to save processed images and detected points for analysis.
- Improves detection robustness across varying lighting, contrast, and UI themes while maintaining precise click alignment.

This upgrade significantly strengthens keyword recognition reliability and unifies coordinate handling across all detection phases.
2025-05-01 21:57:14 +08:00
2025-04-21 15:48:13 +08:00
2025-04-30 01:53:10 +08:00
2025-04-26 14:39:57 +08:00
2025-05-01 21:57:14 +08:00
2025-04-26 14:00:26 +08:00
2025-04-26 14:00:26 +08:00
2025-04-17 01:28:22 +08:00
2025-04-22 22:42:07 +08:00
2025-04-20 14:46:04 +08:00
2025-05-01 21:57:14 +08:00

Wolf Chat - Last War Game Automated Chat Assistant

Project Overview

Wolf Chat is a chatbot assistant designed specifically for integration with "Last War-Survival Game," using screen recognition technology to monitor the game's chat window and automatically respond to messages containing keywords.

This bot will:

  • Automatically monitor the game chat window
  • Detect chat messages containing the keywords "wolf" or "Wolf"
  • Generate responses using a language model
  • Automatically input responses into the game chat interface

Main Features

  • Language Model Integration: Supports OpenAI API or compatible AI services for intelligent response generation
  • MCP Framework: Modular Capability Provider architecture supporting extended functionality and tool calls
  • Persona System: Provides detailed character definition for personality-driven responses
  • Chat Logging: Automatically saves conversation history for contextual understanding

System Requirements

  • Python 3.8+
  • OpenAI API key or compatible service
  • Game client ("Last War-Survival Game")
  • OpenCV, PyAutoGUI, and other dependencies (see requirements.txt)

Installation Guide

  1. Download Method:

    • Download the ZIP file directly from GitHub (click the green "Code" button, select "Download ZIP")
    • Extract to a folder of your choice
  2. Install Dependencies:

    pip install -r requirements.txt
    
  3. Create a .env file with your API keys:

    OPENAI_API_KEY=your_api_key_here
    EXA_API_KEY=your_exa_key_here
    
  4. Capture necessary UI template images (see "UI Setup" section below)

Configuration Settings

  1. API Settings: Edit config.py to set your preferred language model provider:

    OPENAI_API_BASE_URL = "https://openrouter.ai/api/v1" # Or other compatible provider
    LLM_MODEL = "deepseek/deepseek-chat-v3-0324" # Or other model
    
  2. MCP Servers: Configure MCP servers in config.py (if using this feature):

    MCP_SERVERS = {
        "exa": { "command": "cmd", "args": [...] },
        "memorymesh": { "command": "node", "args": [...] }
    }
    
  3. Game Window: Set your game window title in config.py:

    WINDOW_TITLE = "Last War-Survival Game"
    
  4. Chat Persona: Customize persona.json to define the bot's personality traits

UI Setup

The system requires template images of UI elements to function properly:

  1. Run the window setup script to position your game window:

    python window-setup-script.py --launch
    
  2. Capture the following UI elements and save them to the templates folder:

    • Chat bubble corners (regular and bot)
    • Keywords "wolf" and "Wolf"
    • Menu elements like "Copy" button
    • Profile and user detail page elements
    • Capitol icon in the Profile page (critical!)

    Screenshot names should match the constants defined in ui_interaction.py.

  3. Window Monitor Tool: Use the following command to start window monitoring, ensuring the game window stays on top:

    python window-monitor-script.py
    

Usage Instructions

  1. Start the game client

  2. Run the bot:

    python main.py
    
  3. The bot will start monitoring the chat for messages containing "wolf" or "Wolf"

  4. When a keyword is detected, it will:

    • Copy the message content
    • Get the sender's name
    • Process the request using the language model
    • Automatically send a response in the chat

Hotkeys

  • F7: Clear recently processed conversation history
  • F8: Pause/resume the script's main functions (UI monitoring, LLM interaction)
  • F9: Trigger the script's normal shutdown process

Developer Tools

  • LLM Debug Script (test/llm_debug_script.py): Bypasses the UI interaction layer to directly interact with the language model for debugging, useful for testing prompts and MCP tool calls

Troubleshooting

  • Template Recognition Issues: Adjust the CONFIDENCE_THRESHOLD in ui_interaction.py
  • MCP Connection Errors: Check server configurations in config.py
  • API Errors: Verify your API keys in the .env file
  • UI Automation Failures: Update template images to match your client's appearance
  • Window Position Issues: Ensure the game window stays in the correct position, use window-monitor-script.py
Description
No description provided
Readme 892 KiB
Languages
Python 100%