This commit is contained in:
cdle
2021-09-10 17:49:19 +08:00
parent fd718b85b4
commit 5cd34e397c
2 changed files with 49 additions and 0 deletions
+1
View File
@@ -34,6 +34,7 @@ func init() {
core.AddCommand("jd", []core.Function{
{
Rules: []string{`asset ?`},
Admin: true,
Handle: func(s im.Sender) interface{} {
a := s.Get()
envs, err := qinglong.GetEnvs("JD_COOKIE")
+48
View File
@@ -195,6 +195,54 @@ func init() {
return data
},
},
{
Rules: []string{`cron hide duplicate`},
Admin: true,
Handle: func(s im.Sender) interface{} {
w := func(s string) int {
if strings.Contains(s, "shufflewzc") {
return 1
}
if strings.Contains(s, "novpx") {
return 10
}
if strings.Contains(s, "smiek2221") {
return 9
}
if strings.Contains(s, "Aaron-lv") {
return 8
}
return 0
}
crons, err := GetCrons("")
if err != nil {
return err
}
tasks := map[string]Cron{}
for i := range crons {
if crons[i].IsDisabled != 0 {
continue
}
if task, ok := tasks[crons[i].Name]; ok {
var dup Cron
if w(task.Command) > w(crons[i].Command) {
dup = crons[i]
} else {
dup = task
tasks[crons[i].Name] = crons[i]
}
if err := Req(CRONS, PUT, "/disable", []byte(fmt.Sprintf(`["%s"]`, dup.ID))); err != nil {
s.Reply(fmt.Sprintf("隐藏 %v %v %v", dup.Name, dup.Command, err))
} else {
s.Reply(fmt.Sprintf("已隐藏重复任务 %v %v", dup.Name, dup.Command))
}
} else {
tasks[crons[i].Name] = crons[i]
}
}
return "操作成功"
},
},
})
}