refactor(internal): 分离runner
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package bilibili
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// BilibiliDynamicRuleValidator B站动态规则验证器
|
||||
type BilibiliDynamicRuleValidator struct{}
|
||||
|
||||
func (v *BilibiliDynamicRuleValidator) GetType() string {
|
||||
return "bilibili-dynamic"
|
||||
}
|
||||
|
||||
func (v *BilibiliDynamicRuleValidator) Validate(configJSON string) error {
|
||||
var config BiliDynamicConfig
|
||||
if err := json.Unmarshal([]byte(configJSON), &config); err != nil {
|
||||
return fmt.Errorf("解析B站动态规则配置失败: %v", err)
|
||||
}
|
||||
|
||||
if config.Msg == "" {
|
||||
return fmt.Errorf("B站动态规则配置中 msg 不能为空")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package bilibili
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/ssdomei232/goodBaby/model"
|
||||
)
|
||||
|
||||
// BilibiliDynamicExecutor B站动态执行器
|
||||
type BilibiliDynamicExecutor struct{}
|
||||
|
||||
func (e *BilibiliDynamicExecutor) GetType() string {
|
||||
return "bilibili-dynamic"
|
||||
}
|
||||
|
||||
func (e *BilibiliDynamicExecutor) Execute(rule *model.Rule) error {
|
||||
log.Printf("执行B站动态规则: %s (ID: %d)", rule.Name, rule.ID)
|
||||
|
||||
SendBiliDynamicMsg(rule)
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user