后端: - 修复登录校验、DB 并发(单例+WAL+纯Go sqlite)、会话密钥持久化等核心缺陷 - 新增 Timer CRUD/签到/手动触发、执行日志、仪表盘、驱动元数据等 API - 统一驱动接口: 带 context 的执行器、真实错误返回、敏感字段掩码、连通性测试 - 补全钉钉执行器; Timer 触发/提醒去重; 配置支持默认值与环境变量覆盖 前端: - Vite+Vue3+TS+Pinia+Element Plus, 由驱动元数据动态渲染配置表单 - 登录/仪表盘(倒计时环)/定时器/规则/账号/日志/设置页面, 支持暗色模式 - 主题色 #66ccff, 信号波纹 logo, go:embed 单二进制部署 构建: Dockerfile 增加前端构建阶段; 补充各驱动配置文档 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package onebot
|
|
|
|
const (
|
|
// AccountType OneBot 账号类型标识
|
|
AccountType = "onebot"
|
|
// RuleType 发送 OneBot 消息的规则类型标识
|
|
RuleType = "onebot"
|
|
)
|
|
|
|
type OneBotConfig struct {
|
|
SendGroups []int64 `json:"send_groups"` // 群号列表
|
|
SendUsers []int64 `json:"send_users"` // 好友 QQ 号列表
|
|
Msg string `json:"msg"`
|
|
}
|
|
|
|
type OneBotAccount struct {
|
|
URL string `json:"url"` // 例如 "http://localhost:5700"
|
|
Token string `json:"token"` // 例如 "your_token_here"
|
|
}
|
|
|
|
// apiResponse OneBot HTTP API 的通用响应信封
|
|
type apiResponse struct {
|
|
Status string `json:"status"`
|
|
Retcode int `json:"retcode"`
|
|
Message string `json:"message"`
|
|
Wording string `json:"wording"`
|
|
}
|
|
|
|
// err 把 OneBot 返回的业务错误转换成 Go error
|
|
func (r *apiResponse) err() error {
|
|
if r.Status == "ok" && r.Retcode == 0 {
|
|
return nil
|
|
}
|
|
detail := r.Wording
|
|
if detail == "" {
|
|
detail = r.Message
|
|
}
|
|
if detail == "" {
|
|
detail = "请检查 OneBot 地址与 Token"
|
|
}
|
|
return &APIError{Status: r.Status, Retcode: r.Retcode, Detail: detail}
|
|
}
|
|
|
|
// APIError OneBot 返回的业务错误
|
|
type APIError struct {
|
|
Status string
|
|
Retcode int
|
|
Detail string
|
|
}
|
|
|
|
func (e *APIError) Error() string {
|
|
return "OneBot 返回错误(status=" + e.Status + "): " + e.Detail
|
|
}
|