feat: 模块化命令框架 + runbook 严格断言与查询结果回传

- core/module: 命令模板、门控(feature flag/confirm/dry-run)、ecode 错误标签、ResultFormatter
- runbook executor: http.get/http.post/assert.json(expect_success 严格断言)、目标主机管理、任务落库、最终 stdout 直接回传
- cf 模块: /cf dns list 支持域名自动解析 zone_id;dns list/zones/workers list 格式化回传;API success:false 判真失败
- 全部 CF/CPA runbook 接入严格断言,杜绝假阳性 success
- 新增 cpa/cfdav/mail/sub 模块与 runbooks;QQ 订阅到期提醒调度
- Web 后台: 模块设置(CF/CPA/cfdav/AI)、OPS 任务、渠道管理、审计页
This commit is contained in:
2026-09-13 07:42:17 +08:00
parent 9085c490f3
commit 81939825d1
86 changed files with 6885 additions and 467 deletions
+13 -5
View File
@@ -9,9 +9,10 @@ import (
"strings"
"time"
"xiaji-go/internal/channel"
"xiaji-go/internal/service"
"xiaji-go/models"
"ops-assistant/internal/channel"
"ops-assistant/internal/core/ops"
"ops-assistant/internal/service"
"ops-assistant/models"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
@@ -23,16 +24,18 @@ const DefaultUserID int64 = 1
type Bot struct {
db *gorm.DB
finance *service.FinanceService
opsSvc *ops.Service
appID string
appSecret string
verificationToken string
encryptKey string
}
func NewBot(db *gorm.DB, finance *service.FinanceService, appID, appSecret, verificationToken, encryptKey string) *Bot {
func NewBot(db *gorm.DB, finance *service.FinanceService, opsSvc *ops.Service, appID, appSecret, verificationToken, encryptKey string) *Bot {
return &Bot{
db: db,
finance: finance,
opsSvc: opsSvc,
appID: appID,
appSecret: appSecret,
verificationToken: verificationToken,
@@ -93,9 +96,14 @@ func (b *Bot) handleWebhook(c *gin.Context) {
func (b *Bot) handleText(text string) string {
trim := strings.TrimSpace(text)
if b.opsSvc != nil {
if handled, out := b.opsSvc.Handle(DefaultUserID, trim); handled {
return out
}
}
switch trim {
case "帮助", "help", "/help", "菜单", "功能", "/start":
return "🦞 虾记记账\n\n直接发送消费描述即可记账:\n• 午饭 25元\n• 打车 ¥30\n\n📋 命令:记录/查看、今日/今天、统计"
return "🛠️ Ops-Assistant\n\n直接发送消费描述即可记账:\n• 午饭 25元\n• 打车 ¥30\n\n📋 命令:记录/查看、今日/今天、统计"
case "查看", "记录", "列表", "最近":
items, err := b.finance.GetTransactions(DefaultUserID, 10)
if err != nil {