x
This commit is contained in:
@@ -8,6 +8,6 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script src="/admin/umi.ce22547e.js"></script>
|
||||
<script src="/admin/umi.d07105ee.js"></script>
|
||||
|
||||
</body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+35
-11
@@ -28,6 +28,7 @@ type Sender struct {
|
||||
ChatID string `json:"chat_id"`
|
||||
UserID string `json:"user_id"`
|
||||
Platfrom string `json:"platform"`
|
||||
BotID string `json:"bot_id"`
|
||||
}
|
||||
|
||||
type Tasks struct {
|
||||
@@ -43,6 +44,7 @@ type Tasks struct {
|
||||
Remark string `json:"remark"`
|
||||
Enable bool `json:"enable"`
|
||||
Handle func() `json:"-"`
|
||||
Icons []interface{} `json:"icons"`
|
||||
}
|
||||
|
||||
var pts = []*Tasks{}
|
||||
@@ -51,7 +53,7 @@ func RegistTasks(pt *Tasks) {
|
||||
pt.Handle = func() {
|
||||
content := pt.Command
|
||||
for _, meta := range pt.Senders {
|
||||
adapter, _ := GetAdapter(meta.Platfrom, "")
|
||||
adapter, _ := GetAdapter(meta.Platfrom, meta.BotID)
|
||||
if adapter != nil {
|
||||
sender := adapter.Sender()
|
||||
sender.SetFsps(&common.FakerSenderParams{
|
||||
@@ -96,8 +98,8 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
sort.Sort(byCreatedAt2(pts))
|
||||
for i := range cgs {
|
||||
cgs[i].Index = i + 1
|
||||
for i := range pts {
|
||||
pts[i].Index = i + 1
|
||||
}
|
||||
storage.Watch(tasks, nil, func(old, new, key string) *storage.Final {
|
||||
console.Log("已更新计划任务")
|
||||
@@ -173,6 +175,22 @@ func init() {
|
||||
begin = end
|
||||
}
|
||||
rr.Data = pts[begin:end]
|
||||
for i := range rr.Data {
|
||||
rr.Data[i].Icons = []interface{}{}
|
||||
for _, script := range rr.Data[i].Scripts {
|
||||
for _, f := range Functions {
|
||||
if f.UUID == script {
|
||||
if f.Icon != "" {
|
||||
rr.Data[i].Icons = append(rr.Data[i].Icons, map[string]interface{}{
|
||||
"link": f.Icon,
|
||||
"title": f.Title,
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ctx.JSON(200, rr)
|
||||
})
|
||||
GinApi(POST, "/api/tasks", RequireAuth, func(ctx *gin.Context) {
|
||||
@@ -230,6 +248,7 @@ func init() {
|
||||
"success": false,
|
||||
"errorMessage": "Senders错误:" + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
tp.Senders = ss
|
||||
case "command":
|
||||
@@ -319,28 +338,33 @@ func init() {
|
||||
err := json.Unmarshal(b2, v)
|
||||
if err == nil {
|
||||
if v.Group {
|
||||
if Contains(user_ids, code) {
|
||||
user_names = append(user_names, NicklabeL{
|
||||
Label: fmt.Sprintf("%s(%s)", v.Value, code),
|
||||
Value: code,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if Contains(chat_ids, code) {
|
||||
group_names = append(group_names, NicklabeL{
|
||||
Label: fmt.Sprintf("%s(%s)", v.Value, code),
|
||||
Value: code,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if Contains(user_ids, code) {
|
||||
user_names = append(user_names, NicklabeL{
|
||||
Label: fmt.Sprintf("%s(%s)", v.Value, code),
|
||||
Value: code,
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
platforms := map[string][]string{}
|
||||
for _, plt := range getPltsArray() {
|
||||
platforms[plt] = GetAdapterBotsID(plt)
|
||||
}
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
"success": true,
|
||||
"data": map[string]interface{}{
|
||||
"scripts": scripts,
|
||||
"platforms": getPltsArray(),
|
||||
"platforms": platforms,
|
||||
"user_names": user_names,
|
||||
"group_names": group_names,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user