Skip to content

Commit

Permalink
fix: 记录Rd从缓存获取
Browse files Browse the repository at this point in the history
  • Loading branch information
rehiy committed Mar 15, 2024
1 parent 7c6ee75 commit d22ec56
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 0 additions & 1 deletion build/plugin/cronjob/ping.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// 这是一个计划任务插件,用于测试计划任务能否正常工作
// 参数中的 Rd 不要重复,且导入后不可随意修改,否则将影响插件的更新
// @Rd: 100
// @Name: Ping
// @Second: 0
// @Minute: 0
Expand Down
1 change: 0 additions & 1 deletion build/plugin/keyword/ping.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// 这是一个自定义指令插件,用于测试自定义指令能否正常工作
// 参数中的 Rd 不要重复,且导入后不可随意修改,否则将影响插件的更新
// @Rd: 100
// @Roomid: *
// @Phrase: ping
// @Level: 9
Expand Down
6 changes: 4 additions & 2 deletions wclient/plugin/cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ func CronjobPluginSetup() ([]*CronjobPlugin, error) {
}
// 更新插件信息
errstr := ""
if checker.Get(rp) == 0 {
config.Rd = checker.Get(rp)
if config.Rd == 0 {
if rd, err := cronjob.Create(config); err == nil {
checker.Put(rp, rd)
config.Rd = rd
} else {
errstr = err.Error()
}
Expand All @@ -63,7 +65,7 @@ func CronjobPluginParser(fp string) (*cronjob.CreateParam, error) {
}

// 提取插件参数
re := regexp.MustCompile(`(?m)^(//|::)\s*@(Rd|Name|Second|Minute|Hour|DayOfMonth|Month|DayOfWeek|Timeout|Content|Deliver):\s*(.*)$`)
re := regexp.MustCompile(`(?m)^(//|::)\s*@(Name|Second|Minute|Hour|DayOfMonth|Month|DayOfWeek|Timeout|Content|Deliver):\s*(.*)$`)
matches := re.FindAllStringSubmatch(string(content), -1)
if matches == nil {
return nil, fmt.Errorf("cronjob config not found")
Expand Down
6 changes: 4 additions & 2 deletions wclient/plugin/keyword.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ func KeywordPluginSetup() ([]*KeywordPlugin, error) {
}
// 更新插件信息
errstr := ""
if checker.Get(rp) == 0 {
config.Rd = checker.Get(rp)
if config.Rd == 0 {
if rd, err := keyword.Create(config); err == nil {
checker.Put(rp, rd)
config.Rd = rd
} else {
errstr = err.Error()
}
Expand All @@ -63,7 +65,7 @@ func KeywordPluginParser(fp string) (*keyword.CreateParam, error) {
}

// 提取插件参数
re := regexp.MustCompile(`(?m)^(//|::)\s*@(Rd|Roomid|Phrase|Level|Target|Remark):\s*(.*)$`)
re := regexp.MustCompile(`(?m)^(//|::)\s*@(Roomid|Phrase|Level|Target|Remark):\s*(.*)$`)
matches := re.FindAllStringSubmatch(string(content), -1)
if matches == nil {
return nil, fmt.Errorf("command config not found")
Expand Down

0 comments on commit d22ec56

Please sign in to comment.