Introduction to yu-auto-reply
Overview
The yu-auto-reply project, developed by the author known as 程序员鱼皮, is a sophisticated tool designed to perform platform monitoring and automated replies. Built using Java Spring Boot, this tool offers flexibility in configuring various monitoring tasks and supports one-click deployment. It's tailored for users who seek an efficient way to handle queries on different platforms with minimal manual effort. A demonstration video is available on Bilibili for a better understanding of its capabilities.
The project's architecture uses multiple design patterns to decouple the monitoring and replying components, allowing users to configure distinct platforms and link different types of automated responses flexibly.
Key Features
Monitoring Capabilities
- Knowledge Planet Query Monitoring: Keeps track of questions on the Knowledge Planet platform.
- Default Monitoring: Employs simulated data to serve as a default monitoring setup.
Replying Capabilities
- OpenAI Responses: Supports using various models such as GPT-4 for automated replies.
- Default Replying: Utilizes simulated data for basic reply functions.
Configuration Flexibility
- Multiple tasks can be configured at once.
- Each task can be uniquely tailored with specific monitoring and replying methods.
Deployment Ease
- Docker Support: The tool can be easily deployed in a Docker container.
- Railway Deployment: Facilitates one-click deployment via Railway.
- Environment variables can be dynamically set to adjust configurations.
Getting Started
To quickly start using yu-auto-reply, follow these steps:
-
Modify the
application.yml
Configuration: The file is divided into three main sections that need adjustment:- OpenAI Configuration: An API Key is required.
- Knowledge Planet Configuration: Users need to obtain cookies themselves.
- Task Configuration
A sample configuration looks like this:
# openAI configuration openai: model: ${OPENAI_MODEL:text-davinci-003} apiKey: ${OPENAI_API_KEY:yourApiKey} # Knowledge Planet configuration zsxq: cookie: ${ZSXQ_COOKIE:yourPlanetCookie} groupId: ${ZSXQ_GROUP_ID:yourPlanetId} silenced: ${ZSXQ_SILENCED:true} # Task configuration task: list: - name: task1 monitor: zsxq answerer: openai cron: '0/30 * * * * ?'
-
Run the Main Application: Execute the
MainApplication
class to start the service.
One-Click Deployment
The project can be deployed with a single click on Railway. Clicking the deployment button will automatically recognize and update environment variables accordingly.
Architectural Design
The key design principle of this project is the decoupling of monitors and answerers, allowing the monitoring of any platform, each with potentially different automatic responses, such as those provided by OpenAI. Important design implementations include:
- Defining the
Answerer
interface which standardizes methods for answering. - Defining the
Monitor
interface which standardizes monitoring methods and uses callback parameters for automated replies. - Utilizing the mediator pattern with a
JobMediator
class to combineMonitor
andAnswerer
instead of tightly binding them. - Employing the factory pattern to generate monitors and answerers based on configurations.
- Utilizing Spring Scheduler to read YAML configurations and automatically create multiple tasks.
Development
Custom Monitoring
- Create a class that implements the
monitor/Monitor
abstract class. - Modify the
createMonitor
method infactory/MonitorFactory
to include your custom monitor.
Custom Replying
- Create a class that implements the
answerer/Answerer
interface. - Modify the
createAnswerer
method infactory/AnswererFactory
to include your custom answerer.
Community and Contributions
The author encourages contributions despite being busy, and invites users to raise issues and submit pull requests. Those interested in programming guidance or project tutorials can visit the Programming Navigation Knowledge Planet.
FAQs
- Why is Knowledge Planet supported first? The OpenAI API isn't free, and Knowledge Planet helps limit query frequency to prevent excessive API use.