update README.md

This commit is contained in:
z060142 2025-04-22 22:42:07 +08:00
parent 37277e0282
commit 74005e65d6

View File

@ -1,63 +1,57 @@
# Wolf Chat Bot # Wolf Chat - Last War Game Automated Chat Assistant
A specialized chat assistant that integrates with the "Last War-Survival Game" by monitoring the game's chat window using screen recognition technology. ## Project Overview
## 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 project implements an AI assistant that: This bot will:
- Monitors the game chat window using computer vision - Automatically monitor the game chat window
- Detects messages containing keywords ("wolf" or "Wolf") - Detect chat messages containing the keywords "wolf" or "Wolf"
- Processes requests through a language model - Generate responses using a language model
- Automatically responds in the game chat - Automatically input responses into the game chat interface
The code is developed in English, but supports Traditional Chinese interface and logs for broader accessibility. ## Main Features
## 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
- **Image-based Chat Monitoring**: Uses OpenCV and PyAutoGUI to detect chat bubbles and keywords ## System Requirements
- **Language Model Integration**: Uses GPT models or compatible AI services
- **MCP Framework**: Integrates with Modular Capability Provider for extensible features
- **Persona System**: Supports detailed character persona definition
- **Automated UI Interaction**: Handles copy/paste operations and menu navigation
## Requirements
- Python 3.8+ - Python 3.8+
- OpenAI API key or compatible service - OpenAI API key or compatible service
- MCP Framework
- Game client ("Last War-Survival Game") - Game client ("Last War-Survival Game")
- OpenCV, PyAutoGUI, and other dependencies (see requirements.txt) - OpenCV, PyAutoGUI, and other dependencies (see requirements.txt)
## Installation ## Installation Guide
1. Clone this repository: 1. **Download Method**:
``` - Download the ZIP file directly from GitHub (click the green "Code" button, select "Download ZIP")
git clone [repository-url] - Extract to a folder of your choice
cd dandan
```
2. Install required packages: 2. **Install Dependencies**:
``` ```
pip install -r requirements.txt pip install -r requirements.txt
``` ```
3. Create a `.env` file with your API keys: 3. **Create a `.env` file** with your API keys:
``` ```
OPENAI_API_KEY=your_api_key_here OPENAI_API_KEY=your_api_key_here
EXA_API_KEY=your_exa_key_here EXA_API_KEY=your_exa_key_here
``` ```
4. Capture required UI template images (see "UI Setup" section) 4. **Capture necessary UI template images** (see "UI Setup" section below)
## Configuration ## Configuration Settings
1. **API Settings**: Edit `config.py` to set up your preferred language model provider: 1. **API Settings**: Edit `config.py` to set your preferred language model provider:
```python ```python
OPENAI_API_BASE_URL = "https://openrouter.ai/api/v1" # Or other compatible provider OPENAI_API_BASE_URL = "https://openrouter.ai/api/v1" # Or other compatible provider
LLM_MODEL = "deepseek/deepseek-chat-v3-0324" # Or other model LLM_MODEL = "deepseek/deepseek-chat-v3-0324" # Or other model
``` ```
2. **MCP Servers**: Configure MCP servers in `config.py`: 2. **MCP Servers**: Configure MCP servers in `config.py` (if using this feature):
```python ```python
MCP_SERVERS = { MCP_SERVERS = {
"exa": { "command": "cmd", "args": [...] }, "exa": { "command": "cmd", "args": [...] },
@ -70,26 +64,32 @@ The code is developed in English, but supports Traditional Chinese interface and
WINDOW_TITLE = "Last War-Survival Game" WINDOW_TITLE = "Last War-Survival Game"
``` ```
4. **Chat Persona**: Customize `persona.json` to define the bot's personality 4. **Chat Persona**: Customize `persona.json` to define the bot's personality traits
## UI Setup ## UI Setup
The system requires template images of UI elements to function properly: The system requires template images of UI elements to function properly:
1. Run the window setup script to position your game window: 1. **Run the window setup script** to position your game window:
``` ```
python window-setup-script.py --launch python window-setup-script.py --launch
``` ```
2. Capture the following UI elements and save them to the `templates` folder: 2. **Capture the following UI elements** and save them to the `templates` folder:
- Chat bubble corners (regular and bot) - Chat bubble corners (regular and bot)
- Keywords "wolf" and "Wolf" - Keywords "wolf" and "Wolf"
- Menu elements like "Copy" button - Menu elements like "Copy" button
- Profile and user detail page elements - Profile and user detail page elements
- **Capitol icon in the Profile page** (critical!)
Screenshot names should match the constants defined in `ui_interaction.py`. Screenshot names should match the constants defined in `ui_interaction.py`.
## Usage 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 1. Start the game client
@ -100,25 +100,21 @@ The system requires template images of UI elements to function properly:
3. The bot will start monitoring the chat for messages containing "wolf" or "Wolf" 3. The bot will start monitoring the chat for messages containing "wolf" or "Wolf"
4. When detected, it will: 4. When a keyword is detected, it will:
- Copy the message content - Copy the message content
- Get the sender's name - Get the sender's name
- Process the request using the language model - Process the request using the language model
- Automatically send a response in chat - Automatically send a response in the chat
## How It Works ## Hotkeys
1. **Monitoring**: The UI thread continuously scans the screen for chat bubbles - **F7**: Clear recently processed conversation history
2. **Detection**: When a bubble with "wolf" keyword is found, the message is extracted - **F8**: Pause/resume the script's main functions (UI monitoring, LLM interaction)
3. **Processing**: The message is sent to the language model with the persona context - **F9**: Trigger the script's normal shutdown process
4. **Response**: The AI generates a response based on the persona
5. **Interaction**: The system automatically inputs the response in the game chat
## Developer Tools ## Developer Tools
- **Window Setup Script**: Helps position the game window for UI template capture - **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
- **UI Interaction Debugging**: Can be tested independently by running `ui_interaction.py`
- **Persona Customization**: Edit `persona.json` to change the bot's character
## Troubleshooting ## Troubleshooting
@ -126,4 +122,4 @@ The system requires template images of UI elements to function properly:
- **MCP Connection Errors**: Check server configurations in `config.py` - **MCP Connection Errors**: Check server configurations in `config.py`
- **API Errors**: Verify your API keys in the `.env` file - **API Errors**: Verify your API keys in the `.env` file
- **UI Automation Failures**: Update template images to match your client's appearance - **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`