# NapCatBackend **Repository Path**: hamster-squad/nap-cat-backend ## Basic Information - **Project Name**: NapCatBackend - **Description**: NapCat后台服劑 - **Primary Language**: C# - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-10-12 - **Last Updated**: 2025-11-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # NapCat Backend Project This is a backend project based on the ABP framework, primarily used for connecting and managing robots using the OneBot protocol. The project provides a OneBot-compatible backend service for QQ robots and supports various operations such as message sending, group management, file uploads, and more. ## πŸ“Œ Features - **OneBot Compatible**: Supports robots compatible with the OneBot protocol, enabling easy access to QQ robot services. - **Message Handling**: Supports sending and receiving private and group messages. - **Group Management**: Supports operations such as retrieving group information, kicking members, muting, and setting administrators. - **File Management**: Supports file uploads and downloads. - **Event Listening**: Supports listening for various events, such as group member changes and message deletions. - **Persistence Support**: Database operations are supported through the EFCore module, using SQLite for data storage. ## πŸ“¦ Module Structure - **Application**: Application layer containing business logic interfaces and implementations, such as `TalkService`. - **Domain**: Domain layer containing entities, value objects, domain services, etc., such as the `Talk` entity. - **EFCore**: Data access layer implementing database operations using Entity Framework Core. - **Core**: Core service layer containing background services like `NapCatEventService`, used for handling OneBot events. - **Websocket**: Provides WebSocket connection and communication support, enabling real-time interaction with OneBot. ## πŸ› οΈ Key Features - **Talk Management**: Supports keyword-triggered auto-reply functionality. - **OneBot Client**: Encapsulates the complete OneBot API, supporting asynchronous calls. - **Event Handling**: Supports automatic handling of OneBot events, such as message reception and group member changes. - **Database Migration**: Supports database migration and initialization through EFCore. ## πŸš€ Quick Start ### Requirements - .NET 6 SDK or later - SQLite database support - OneBot-compatible robot service (e.g., [go-cqhttp](https://github.com/Mrs4s/go-cqhttp)) ### Installation Steps 1. **Clone the Project** ```bash git clone https://gitee.com/hamster-squad/nap-cat-backend cd nap-cat-backend ``` 2. **Configure OneBot Connection** Modify the `appsettings.json` file to configure the OneBot connection: ```json { "OneBot": { "Host": "127.0.0.1", "Port": 8080, "Token": "your_token" } } ``` 3. **Run Database Migration** ```bash dotnet ef database update ``` 4. **Start the Project** ```bash dotnet run ``` ## πŸ“š API Examples ### Talk Auto-Reply - **Get Reply**: Retrieve auto-reply content based on a keyword ```csharp var content = await talkService.GetContent("Hello"); ``` - **Create Reply**: ```csharp var talk = new Talk { Keyword = "Hello", Content = "Hello, world!" }; await talkService.CreateAsync(talk); ``` ### OneBot Operations - **Send Group Message**: ```csharp var message = new Message(); message.Add(new MessageSegment("text", new Dictionary { { "text", "Hello Group!" } })); await client.SendGroupMessageAsync("123456", message); ``` - **Get Group Member List**: ```csharp var receipt = await client.GetGroupMemberListAsync("123456"); ``` ## 🀝 Contribution Guide Pull Requests and Issues are welcome. Please follow the project's coding style and ensure tests pass before submitting. ## πŸ“„ License This project is licensed under the MIT License. For details, please refer to the [LICENSE](LICENSE) file.