init
This commit is contained in:
commit
5f8428a318
1688 files changed
+39031
No files matched your search
@@ -0,0 +1,14 @@
|
||||
**/bin/
|
||||
**/obj/
|
||||
**/node_modules/
|
||||
**/.git/
|
||||
**/.vs/
|
||||
**/publish/
|
||||
**/publish-linux/
|
||||
**/*.zip
|
||||
**/data/
|
||||
record-bot/data/
|
||||
weixin-ilink-gateway/data/
|
||||
**/.env
|
||||
**/appsettings.local.json
|
||||
**/appsettings.*.local.json
|
||||
@@ -0,0 +1,31 @@
|
||||
# Copy to .env before docker compose up
|
||||
# 生产分开部署、无源码:用 deploy/ 下的 compose + deploy/.env.example
|
||||
|
||||
# 镜像(有则直接 pull,不必在服务器 build)
|
||||
GATEWAY_IMAGE=ghcr.io/kadxy/weixin-ilink-gateway:latest
|
||||
RECORD_BOT_IMAGE=record-bot:local
|
||||
|
||||
# 必填:gateway 与 record-bot 共用
|
||||
GATEWAY_API_KEY=change-me-openssl-rand-hex-16
|
||||
|
||||
# 对外端口(1Panel 可再做反向代理)
|
||||
GATEWAY_PORT=29527
|
||||
RECORD_BOT_PORT=5080
|
||||
|
||||
# 数据目录(相对 compose 工作目录,或写绝对路径如 /opt/wechatbot/data/...)
|
||||
GATEWAY_DATA_DIR=./data/gateway
|
||||
RECORD_DATA_DIR=./data/record-bot
|
||||
|
||||
# gateway → record-bot(同 compose 网络默认即可)
|
||||
WEBHOOK_URLS=http://record-bot:8080/webhook/weixin
|
||||
|
||||
# 可选
|
||||
RECORD_WEBHOOK_TOKEN=
|
||||
GATEWAY_WEBHOOK_TOKEN=
|
||||
MAX_DOWNLOAD_SIZE_MB=128
|
||||
|
||||
# 千问(聊天 / 意图)
|
||||
LLM_ENABLED=true
|
||||
LLM_API_KEY=
|
||||
LLM_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1
|
||||
LLM_MODEL=qwen3.8-max
|
||||
@@ -0,0 +1,37 @@
|
||||
# 复制为 .env,放在 1Panel 编排工作目录(可与 compose 同目录)
|
||||
# 服务器只需:本 .env + compose yaml + 数据目录,不要源码
|
||||
|
||||
# ---------- 镜像(改程序 = 本机重新 push,服务器 pull 新 tag)----------
|
||||
GATEWAY_IMAGE=ghcr.io/kadxy/weixin-ilink-gateway:latest
|
||||
# 换成你的仓库,例如 docker.io/你的用户名/record-bot:latest
|
||||
RECORD_BOT_IMAGE=docker.io/YOUR_DOCKERHUB_USER/record-bot:latest
|
||||
|
||||
# ---------- 密钥 ----------
|
||||
GATEWAY_API_KEY=change-me
|
||||
|
||||
# ---------- 端口 ----------
|
||||
GATEWAY_PORT=29527
|
||||
RECORD_BOT_PORT=5080
|
||||
|
||||
# ---------- 数据(绝对路径更稳,如 /opt/wechatbot/data/...)----------
|
||||
GATEWAY_DATA_DIR=./data/gateway
|
||||
RECORD_DATA_DIR=./data/record-bot
|
||||
|
||||
# ---------- 互相访问(分开部署、同一 Docker 网络 wechatbot 时)----------
|
||||
WEBHOOK_URLS=http://record-bot:8080/webhook/weixin
|
||||
GATEWAY_BASE_URL=http://weixin-ilink-gateway:3000
|
||||
|
||||
# 若两个编排不在同一网络,改用宿主机端口,例如:
|
||||
# WEBHOOK_URLS=http://host.docker.internal:5080/webhook/weixin
|
||||
# GATEWAY_BASE_URL=http://host.docker.internal:29527
|
||||
|
||||
DOCKER_NETWORK=wechatbot
|
||||
|
||||
RECORD_WEBHOOK_TOKEN=
|
||||
GATEWAY_WEBHOOK_TOKEN=
|
||||
MAX_DOWNLOAD_SIZE_MB=128
|
||||
|
||||
LLM_ENABLED=true
|
||||
LLM_API_KEY=
|
||||
LLM_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1
|
||||
LLM_MODEL=qwen3.8-max
|
||||
@@ -0,0 +1,37 @@
|
||||
@echo off
|
||||
setlocal EnableDelayedExpansion
|
||||
cd /d "%~dp0.."
|
||||
|
||||
REM ============================================================
|
||||
REM 本机构建并推送镜像;服务器只 docker compose pull && up -d
|
||||
REM 用法:
|
||||
REM deploy\build-push.bat
|
||||
REM set RECORD_BOT_IMAGE=youruser/record-bot:1.0.1 && deploy\build-push.bat
|
||||
REM ============================================================
|
||||
|
||||
if "%RECORD_BOT_IMAGE%"=="" (
|
||||
echo Set RECORD_BOT_IMAGE first, e.g.:
|
||||
echo set RECORD_BOT_IMAGE=youruser/record-bot:latest
|
||||
echo deploy\build-push.bat
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo === Build record-bot → %RECORD_BOT_IMAGE% ===
|
||||
docker build -t "%RECORD_BOT_IMAGE%" -f record-bot\Dockerfile record-bot
|
||||
if errorlevel 1 exit /b 1
|
||||
|
||||
echo.
|
||||
echo === Push %RECORD_BOT_IMAGE% ===
|
||||
docker push "%RECORD_BOT_IMAGE%"
|
||||
if errorlevel 1 (
|
||||
echo Push failed. Login first: docker login
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo OK. On server:
|
||||
echo docker compose -f record-bot.compose.yaml pull
|
||||
echo docker compose -f record-bot.compose.yaml up -d
|
||||
echo Or in 1Panel: 重建/拉取镜像后重启容器。
|
||||
endlocal
|
||||
@@ -0,0 +1,54 @@
|
||||
# 本机构建并推送;服务器只 pull 镜像,无需源码
|
||||
# 用法:
|
||||
# $env:RECORD_BOT_IMAGE = "youruser/record-bot:1.0.1"
|
||||
# .\deploy\build-push.ps1
|
||||
# 可选同时构建自己的 gateway(一般用官方镜像即可):
|
||||
# $env:GATEWAY_IMAGE = "youruser/weixin-ilink-gateway:latest"
|
||||
# .\deploy\build-push.ps1 -IncludeGateway
|
||||
|
||||
param(
|
||||
[switch]$IncludeGateway
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$root = Split-Path -Parent $PSScriptRoot
|
||||
Set-Location $root
|
||||
|
||||
if (-not $env:RECORD_BOT_IMAGE) {
|
||||
Write-Host @"
|
||||
请先设置镜像名,例如:
|
||||
`$env:RECORD_BOT_IMAGE = 'youruser/record-bot:latest'
|
||||
.\deploy\build-push.ps1
|
||||
"@
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "=== Build record-bot → $($env:RECORD_BOT_IMAGE) ==="
|
||||
docker build -t $env:RECORD_BOT_IMAGE -f record-bot/Dockerfile record-bot
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
|
||||
Write-Host "=== Push $($env:RECORD_BOT_IMAGE) ==="
|
||||
docker push $env:RECORD_BOT_IMAGE
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Push 失败,先执行: docker login"
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
|
||||
if ($IncludeGateway) {
|
||||
if (-not $env:GATEWAY_IMAGE) {
|
||||
Write-Host "IncludeGateway 需要设置 GATEWAY_IMAGE"
|
||||
exit 1
|
||||
}
|
||||
Write-Host "=== Build gateway → $($env:GATEWAY_IMAGE) ==="
|
||||
docker build -t $env:GATEWAY_IMAGE -f weixin-ilink-gateway/Dockerfile weixin-ilink-gateway
|
||||
docker push $env:GATEWAY_IMAGE
|
||||
}
|
||||
|
||||
Write-Host @"
|
||||
|
||||
完成。服务器更新步骤(无源码):
|
||||
docker compose -f deploy/record-bot.compose.yaml pull
|
||||
docker compose -f deploy/record-bot.compose.yaml up -d
|
||||
|
||||
1Panel: 打开编排 → 拉取镜像 / 重建 即可。
|
||||
"@
|
||||
@@ -0,0 +1,36 @@
|
||||
# 仅 gateway — 服务器上不需要源码,只拉镜像
|
||||
# 1Panel:容器 → 编排,粘贴本文件;配合 .env
|
||||
#
|
||||
# 首次:docker network create wechatbot (与 record-bot 共用,可选)
|
||||
|
||||
services:
|
||||
gateway:
|
||||
image: ${GATEWAY_IMAGE:-ghcr.io/kadxy/weixin-ilink-gateway:latest}
|
||||
container_name: weixin-ilink-gateway
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${GATEWAY_PORT:-29527}:3000"
|
||||
environment:
|
||||
API_KEY: ${GATEWAY_API_KEY:?set GATEWAY_API_KEY}
|
||||
PORT: "3000"
|
||||
DATA_DIR: /app/data
|
||||
# 分开部署时填 record-bot 对外可达地址,例如 http://127.0.0.1:5080/webhook/weixin
|
||||
# 或同 Docker 网络:http://record-bot:8080/webhook/weixin
|
||||
WEBHOOK_URLS: ${WEBHOOK_URLS:?set WEBHOOK_URLS}
|
||||
WEBHOOK_TOKEN: ${GATEWAY_WEBHOOK_TOKEN:-}
|
||||
MAX_DOWNLOAD_SIZE_MB: ${MAX_DOWNLOAD_SIZE_MB:-128}
|
||||
volumes:
|
||||
- ${GATEWAY_DATA_DIR:-./data/gateway}:/app/data
|
||||
networks:
|
||||
- wechatbot
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-qO-", "http://localhost:3000/status"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 15s
|
||||
|
||||
networks:
|
||||
wechatbot:
|
||||
external: true
|
||||
name: ${DOCKER_NETWORK:-wechatbot}
|
||||
@@ -0,0 +1,39 @@
|
||||
# 仅 record-bot — 服务器上不需要源码,只拉镜像
|
||||
# 1Panel:容器 → 编排,粘贴本文件;配合 .env
|
||||
#
|
||||
# 镜像由本机 build-push 推到仓库后,这里改 RECORD_BOT_IMAGE 即可更新
|
||||
|
||||
services:
|
||||
record-bot:
|
||||
image: ${RECORD_BOT_IMAGE:?set RECORD_BOT_IMAGE e.g. docker.io/you/record-bot:latest}
|
||||
container_name: record-bot
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${RECORD_BOT_PORT:-5080}:8080"
|
||||
environment:
|
||||
ASPNETCORE_ENVIRONMENT: Production
|
||||
TZ: Asia/Shanghai
|
||||
# 分开部署:同网络用 http://weixin-ilink-gateway:3000,或宿主机 http://172.17.0.1:29527
|
||||
Gateway__BaseUrl: ${GATEWAY_BASE_URL:-http://weixin-ilink-gateway:3000}
|
||||
Gateway__ApiKey: ${GATEWAY_API_KEY:?set GATEWAY_API_KEY}
|
||||
RecordBot__WebhookToken: ${RECORD_WEBHOOK_TOKEN:-}
|
||||
RecordBot__ReplyOnRecord: "true"
|
||||
RecordBot__ConnectionString: "Data Source=/app/data/records.db"
|
||||
RecordBot__MediaDir: /app/data/media
|
||||
RecordBot__BackupDir: /app/data/backups
|
||||
RecordBot__TimeZoneId: Asia/Shanghai
|
||||
Llm__Enabled: ${LLM_ENABLED:-true}
|
||||
Llm__ApiKey: ${LLM_API_KEY:-}
|
||||
Llm__BaseUrl: ${LLM_BASE_URL:-https://dashscope.aliyuncs.com/compatible-mode/v1}
|
||||
Llm__Model: ${LLM_MODEL:-qwen3.8-max}
|
||||
volumes:
|
||||
- ${RECORD_DATA_DIR:-./data/record-bot}:/app/data
|
||||
networks:
|
||||
- wechatbot
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
|
||||
networks:
|
||||
wechatbot:
|
||||
external: true
|
||||
name: ${DOCKER_NETWORK:-wechatbot}
|
||||
@@ -0,0 +1,17 @@
|
||||
[program:WeChatBot]
|
||||
; Supervisor 不能用 ./RecordBot,必须写绝对路径
|
||||
command = /data/WeChatBot/record-bot/RecordBot/RecordBot
|
||||
directory = /data/WeChatBot/record-bot/RecordBot
|
||||
environment = ASPNETCORE_URLS="http://0.0.0.0:5080",ASPNETCORE_ENVIRONMENT="Production",TZ="Asia/Shanghai"
|
||||
autorestart = true
|
||||
startsecs = 3
|
||||
stdout_logfile = /opt/1panel/tools/supervisord/log/WeChatBot.out.log
|
||||
stderr_logfile = /opt/1panel/tools/supervisord/log/WeChatBot.err.log
|
||||
stdout_logfile_maxbytes = 2MB
|
||||
stderr_logfile_maxbytes = 2MB
|
||||
user = root
|
||||
priority = 999
|
||||
numprocs = 1
|
||||
process_name = %(program_name)s_%(process_num)02d
|
||||
stopasgroup = true
|
||||
killasgroup = true
|
||||
@@ -0,0 +1,18 @@
|
||||
; 1Panel → 创建守护进程(不要只拷 .conf,要用面板创建或保存为同目录 .ini)
|
||||
[program:WeChatGateway]
|
||||
; 若是 bun 编译出的单文件用下面这行;若是 bun run start 则改成 /root/.bun/bin/bun run start
|
||||
command = /data/WeChatBot/weixin-ilink-gateway/server
|
||||
directory = /data/WeChatBot/weixin-ilink-gateway
|
||||
environment = TZ="Asia/Shanghai",PATH="/root/.bun/bin:/usr/local/bin:/usr/bin:/bin"
|
||||
autorestart = true
|
||||
startsecs = 3
|
||||
stdout_logfile = /opt/1panel/tools/supervisord/log/WeChatGateway.out.log
|
||||
stderr_logfile = /opt/1panel/tools/supervisord/log/WeChatGateway.err.log
|
||||
stdout_logfile_maxbytes = 2MB
|
||||
stderr_logfile_maxbytes = 2MB
|
||||
user = root
|
||||
priority = 998
|
||||
numprocs = 1
|
||||
process_name = %(program_name)s_%(process_num)02d
|
||||
stopasgroup = true
|
||||
killasgroup = true
|
||||
@@ -0,0 +1,57 @@
|
||||
# 开发/整包构建用(需要源码)。
|
||||
# 生产分开部署、无源码:用 deploy/gateway.compose.yaml + deploy/record-bot.compose.yaml
|
||||
|
||||
services:
|
||||
gateway:
|
||||
image: ${GATEWAY_IMAGE:-ghcr.io/kadxy/weixin-ilink-gateway:latest}
|
||||
build:
|
||||
context: ./weixin-ilink-gateway
|
||||
dockerfile: Dockerfile
|
||||
container_name: weixin-ilink-gateway
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${GATEWAY_PORT:-29527}:3000"
|
||||
environment:
|
||||
API_KEY: ${GATEWAY_API_KEY:?set GATEWAY_API_KEY}
|
||||
PORT: "3000"
|
||||
DATA_DIR: /app/data
|
||||
WEBHOOK_URLS: ${WEBHOOK_URLS:-http://record-bot:8080/webhook/weixin}
|
||||
WEBHOOK_TOKEN: ${GATEWAY_WEBHOOK_TOKEN:-}
|
||||
MAX_DOWNLOAD_SIZE_MB: ${MAX_DOWNLOAD_SIZE_MB:-128}
|
||||
volumes:
|
||||
- ${GATEWAY_DATA_DIR:-./data/gateway}:/app/data
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-qO-", "http://localhost:3000/status"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 15s
|
||||
|
||||
record-bot:
|
||||
image: ${RECORD_BOT_IMAGE:-record-bot:local}
|
||||
build:
|
||||
context: ./record-bot
|
||||
dockerfile: Dockerfile
|
||||
container_name: record-bot
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- gateway
|
||||
ports:
|
||||
- "${RECORD_BOT_PORT:-5080}:8080"
|
||||
environment:
|
||||
ASPNETCORE_ENVIRONMENT: Production
|
||||
TZ: Asia/Shanghai
|
||||
Gateway__BaseUrl: http://gateway:3000
|
||||
Gateway__ApiKey: ${GATEWAY_API_KEY:?set GATEWAY_API_KEY}
|
||||
RecordBot__WebhookToken: ${RECORD_WEBHOOK_TOKEN:-}
|
||||
RecordBot__ReplyOnRecord: "true"
|
||||
RecordBot__ConnectionString: "Data Source=/app/data/records.db"
|
||||
RecordBot__MediaDir: /app/data/media
|
||||
RecordBot__BackupDir: /app/data/backups
|
||||
RecordBot__TimeZoneId: Asia/Shanghai
|
||||
Llm__Enabled: ${LLM_ENABLED:-true}
|
||||
Llm__ApiKey: ${LLM_API_KEY:-}
|
||||
Llm__BaseUrl: ${LLM_BASE_URL:-https://dashscope.aliyuncs.com/compatible-mode/v1}
|
||||
Llm__Model: ${LLM_MODEL:-qwen3.8-max}
|
||||
volumes:
|
||||
- ${RECORD_DATA_DIR:-./data/record-bot}:/app/data
|
||||
@@ -0,0 +1,15 @@
|
||||
**/bin/
|
||||
**/obj/
|
||||
**/node_modules/
|
||||
**/publish/
|
||||
**/publish-linux/
|
||||
**/data/
|
||||
**/storage/
|
||||
**/.git/
|
||||
**/.vs/
|
||||
**/*.user
|
||||
**/appsettings.local.json
|
||||
**/appsettings.*.local.json
|
||||
web/dist/
|
||||
*.md
|
||||
*.zip
|
||||
@@ -0,0 +1,16 @@
|
||||
bin/
|
||||
obj/
|
||||
data/
|
||||
storage/
|
||||
*.user
|
||||
*.db
|
||||
*.db-shm
|
||||
*.db-wal
|
||||
.vs/
|
||||
.idea/
|
||||
appsettings.local.json
|
||||
appsettings.*.local.json
|
||||
.env
|
||||
web/node_modules/
|
||||
web/dist/
|
||||
src/RecordBot/wwwroot/
|
||||
@@ -0,0 +1,34 @@
|
||||
# Build context: record-bot/ (repo folder that contains web/ and src/)
|
||||
# Multi-stage: Vue admin → .NET publish → slim runtime
|
||||
|
||||
FROM node:22-alpine AS web
|
||||
WORKDIR /web
|
||||
COPY web/package.json web/package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY web/ ./
|
||||
# Override vite outDir so Docker layout does not depend on ../src/RecordBot/wwwroot
|
||||
RUN npx vue-tsc -b && npx vite build --outDir /wwwroot --emptyOutDir
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
WORKDIR /src
|
||||
COPY src/RecordBot/RecordBot.csproj .
|
||||
RUN dotnet restore
|
||||
COPY src/RecordBot/ .
|
||||
COPY --from=web /wwwroot ./wwwroot
|
||||
RUN dotnet publish -c Release -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
|
||||
WORKDIR /app
|
||||
RUN mkdir -p /app/data/media /app/data/backups \
|
||||
&& ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||
&& echo Asia/Shanghai > /etc/timezone
|
||||
ENV ASPNETCORE_URLS=http://+:8080 \
|
||||
TZ=Asia/Shanghai \
|
||||
RecordBot__ConnectionString="Data Source=/app/data/records.db" \
|
||||
RecordBot__MediaDir=/app/data/media \
|
||||
RecordBot__BackupDir=/app/data/backups \
|
||||
RecordBot__TimeZoneId=Asia/Shanghai
|
||||
EXPOSE 8080
|
||||
COPY --from=build /app/publish .
|
||||
VOLUME ["/app/data"]
|
||||
ENTRYPOINT ["dotnet", "RecordBot.dll"]
|
||||
@@ -0,0 +1,127 @@
|
||||
# record-bot
|
||||
|
||||
微信记录助手:接收 `weixin-ilink-gateway` 推送的消息,按规则归类并写入 SQLite,可选回执到微信;带 Vue 管理页。
|
||||
|
||||
技术栈:**.NET 8** / ASP.NET Core Minimal API / EF Core SQLite / **Vue 3 + Vite**。
|
||||
|
||||
## 架构
|
||||
|
||||
```text
|
||||
微信 → weixin-ilink-gateway ──WEBHOOK──► record-bot
|
||||
├─ 关键词归类
|
||||
├─ 图片经 gateway 解密下载
|
||||
├─ SQLite 落库
|
||||
└─ POST /messages/send 回执
|
||||
|
||||
浏览器 ──► Vue 管理页 ──► /records · /records/stats
|
||||
```
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 1. 配置
|
||||
|
||||
编辑 `src/RecordBot/appsettings.Development.json`(或环境变量):
|
||||
|
||||
| 配置 | 说明 |
|
||||
| --- | --- |
|
||||
| `Gateway:BaseUrl` | gateway 地址,本地默认 `http://127.0.0.1:3456` |
|
||||
| `Gateway:ApiKey` | 与 gateway 的 `API_KEY` 相同 |
|
||||
| `RecordBot:WebhookToken` | 可选;设置后要求 `X-Record-Token` 或 `?token=` |
|
||||
| `RecordBot:AllowedUserIds` | 可选白名单;空数组表示接受所有人 |
|
||||
| `RecordBot:ReplyOnRecord` | 记录成功后是否微信回执 |
|
||||
|
||||
### 2. 构建前端并运行 API
|
||||
|
||||
```bash
|
||||
cd web
|
||||
npm install
|
||||
npm run build # 输出到 src/RecordBot/wwwroot
|
||||
|
||||
cd ../src/RecordBot
|
||||
dotnet run
|
||||
```
|
||||
|
||||
打开:`http://localhost:5000/`
|
||||
|
||||
### 3. 前端开发模式(热更新)
|
||||
|
||||
先启动 record-bot(5000),再:
|
||||
|
||||
```bash
|
||||
cd web
|
||||
npm run dev
|
||||
```
|
||||
|
||||
打开 Vite:`http://localhost:5173/`(已代理 `/api` → `http://127.0.0.1:5000`)。
|
||||
|
||||
### 4. 配置 gateway Webhook
|
||||
|
||||
在 `weixin-ilink-gateway` 的 `.env` 中:
|
||||
|
||||
```env
|
||||
WEBHOOK_URLS=http://127.0.0.1:5000/webhook/weixin
|
||||
```
|
||||
|
||||
然后扫码登录 gateway,用手机给 Bot 发消息即可。
|
||||
|
||||
### Docker / 1Panel(Rocky Linux)
|
||||
|
||||
仓库根目录有完整编排(gateway + record-bot,镜像内会编 Vue 管理页):
|
||||
|
||||
```bash
|
||||
cd WeChatBot # 仓库根
|
||||
cp .env.example .env # 填写 GATEWAY_API_KEY、LLM_API_KEY
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
- 管理页:`http://服务器:5080/`
|
||||
- Gateway:`http://服务器:29527/`(扫码登录按 gateway 文档)
|
||||
- 数据:`./data/gateway`、`./data/record-bot`(可改 `.env` 里路径)
|
||||
|
||||
仅部署 record-bot:`cd record-bot && docker compose up -d --build`(需自备 gateway,并设 `GATEWAY_BASE_URL`)。
|
||||
|
||||
无 Docker 时可用 `src/RecordBot/publish-linux.bat` 打 `linux-x64` 自包含包。
|
||||
|
||||
## 用法(微信里发)
|
||||
|
||||
| 你发的内容 | 效果 |
|
||||
| --- | --- |
|
||||
| `提醒我明天8点50打卡` | 到点微信推送「打卡」 |
|
||||
| `明天六点四十提醒我起床` | 支持中文数字时间 |
|
||||
| `每天早上八点五十提醒我打卡` | 每天重复提醒 |
|
||||
| `我的提醒` / `取消提醒 3` | 查看 / 取消定时提醒 |
|
||||
| `#支出 午餐 35` | 归入「支出」,金额 35 |
|
||||
| `支出:买菜 42.5` | 同上 |
|
||||
| `待办 明天交房租` | 归入「待办」 |
|
||||
| 纯文字 | 默认「笔记」 |
|
||||
| 图片 | 默认「照片」,并下载到 `data/media` |
|
||||
| `帮助` / `查询` / `统计` | 命令:说明 / 最近记录 / 本月收支 |
|
||||
|
||||
分类关键词可在 `appsettings.json` → `RecordBot:Categories` 修改。
|
||||
|
||||
## HTTP API
|
||||
|
||||
| 方法 | 路径 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| POST | `/webhook/weixin` | 供 gateway 推送(原始 WeixinMessage JSON) |
|
||||
| GET | `/records?userId=&category=&take=50` | 查询记录 |
|
||||
| GET | `/records/stats?userId=` | 本月统计 |
|
||||
| GET | `/health` | 健康检查 |
|
||||
|
||||
开发环境可打开 Swagger:`http://localhost:5000/swagger`。
|
||||
|
||||
## 目录
|
||||
|
||||
```text
|
||||
record-bot/
|
||||
├── docker-compose.yaml
|
||||
├── README.md
|
||||
├── web/ # Vue 3 管理端
|
||||
└── src/RecordBot/
|
||||
├── Program.cs
|
||||
├── wwwroot/ # npm run build 产出
|
||||
├── Data/
|
||||
├── Models/
|
||||
├── Options/
|
||||
└── Services/
|
||||
```
|
||||
@@ -0,0 +1,8 @@
|
||||
<Solution>
|
||||
<Folder Name="/src/">
|
||||
<Project Path="src/RecordBot/RecordBot.csproj" />
|
||||
</Folder>
|
||||
<Folder Name="/tests/">
|
||||
<Project Path="tests/RecordBot.Tests/RecordBot.Tests.csproj" />
|
||||
</Folder>
|
||||
</Solution>
|
||||
@@ -0,0 +1,31 @@
|
||||
# 本地带源码构建用。生产无源码、分开部署:见 ../deploy/record-bot.compose.yaml
|
||||
|
||||
services:
|
||||
record-bot:
|
||||
image: ${RECORD_BOT_IMAGE:-record-bot:local}
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: record-bot
|
||||
ports:
|
||||
- "${RECORD_BOT_PORT:-5080}:8080"
|
||||
environment:
|
||||
ASPNETCORE_ENVIRONMENT: Production
|
||||
TZ: Asia/Shanghai
|
||||
Gateway__BaseUrl: ${GATEWAY_BASE_URL:-http://host.docker.internal:29527}
|
||||
Gateway__ApiKey: ${GATEWAY_API_KEY:?set GATEWAY_API_KEY}
|
||||
RecordBot__WebhookToken: ${RECORD_WEBHOOK_TOKEN:-}
|
||||
RecordBot__ReplyOnRecord: "true"
|
||||
RecordBot__ConnectionString: "Data Source=/app/data/records.db"
|
||||
RecordBot__MediaDir: /app/data/media
|
||||
RecordBot__BackupDir: /app/data/backups
|
||||
RecordBot__TimeZoneId: Asia/Shanghai
|
||||
Llm__Enabled: ${LLM_ENABLED:-true}
|
||||
Llm__ApiKey: ${LLM_API_KEY:-}
|
||||
Llm__BaseUrl: ${LLM_BASE_URL:-https://dashscope.aliyuncs.com/compatible-mode/v1}
|
||||
Llm__Model: ${LLM_MODEL:-qwen3.8-max}
|
||||
volumes:
|
||||
- ${RECORD_DATA_DIR:-./data}:/app/data
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
restart: unless-stopped
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loaded 100 of 1688 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user