- Implemented `MessageDeduplication` class to suppress duplicate bot replies: - Normalizes sender and message content for reliable comparison. - Tracks processed messages with timestamp-based expiry (default 1 hour). - Integrated into `run_ui_monitoring_loop()` with support for F7/F8-based history resets. - Periodic cleanup thread purges expired entries every 10 minutes. - Added new UI fallback handling logic to address post-update game state changes: - Detects `chat_option.png` overlay before bubble detection and presses ESC to dismiss. - Detects `update_confirm.png` when chat room state is unavailable and clicks it to proceed. - Both behaviors improve UI stability following game version changes. - Updated `essential_templates` dictionary and constants with the two new template paths: - `chat_option.png` - `update_confirm.png` These improvements reduce redundant bot responses and enhance UI resilience against inconsistent or obstructed states in the latest game versions.
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
-
Download Method:
- Download the ZIP file directly from GitHub (click the green "Code" button, select "Download ZIP")
- Extract to a folder of your choice
-
Install Dependencies:
pip install -r requirements.txt -
Create a
.envfile with your API keys:OPENAI_API_KEY=your_api_key_here EXA_API_KEY=your_exa_key_here -
Capture necessary UI template images (see "UI Setup" section below)
Configuration Settings
-
API Settings: Edit
config.pyto 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 -
MCP Servers: Configure MCP servers in
config.py(if using this feature):MCP_SERVERS = { "exa": { "command": "cmd", "args": [...] }, "memorymesh": { "command": "node", "args": [...] } } -
Game Window: Set your game window title in
config.py:WINDOW_TITLE = "Last War-Survival Game" -
Chat Persona: Customize
persona.jsonto define the bot's personality traits
UI Setup
The system requires template images of UI elements to function properly:
-
Run the window setup script to position your game window:
python window-setup-script.py --launch -
Capture the following UI elements and save them to the
templatesfolder:- 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. -
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
-
Start the game client
-
Run the bot:
python main.py -
The bot will start monitoring the chat for messages containing "wolf" or "Wolf"
-
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_THRESHOLDinui_interaction.py - MCP Connection Errors: Check server configurations in
config.py - API Errors: Verify your API keys in the
.envfile - 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