x
This commit is contained in:
+19
-7
@@ -213,7 +213,11 @@ func initCarry() {
|
|||||||
for i, cg := range tmp {
|
for i, cg := range tmp {
|
||||||
if cg.ID == ocg.ID {
|
if cg.ID == ocg.ID {
|
||||||
tmp = append(tmp[:i], tmp[i+1:]...)
|
tmp = append(tmp[:i], tmp[i+1:]...)
|
||||||
RemListenOnGroup(cg.ID, fmt.Sprintf("已为采集群(%s)关闭监听模式", cg.ID))
|
name := cg.ChatName
|
||||||
|
if name == "" {
|
||||||
|
name = cg.ID
|
||||||
|
}
|
||||||
|
RemListenOnGroup(cg.ID, fmt.Sprintf("已为采集群(%s)关闭监听模式", name))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,15 +229,19 @@ func initCarry() {
|
|||||||
for i, cg := range tmp {
|
for i, cg := range tmp {
|
||||||
if cg.ID == ocg.ID {
|
if cg.ID == ocg.ID {
|
||||||
tmp[i] = ncg
|
tmp[i] = ncg
|
||||||
|
name := ncg.ChatName
|
||||||
|
if name == "" {
|
||||||
|
name = ncg.ID
|
||||||
|
}
|
||||||
if ncg.In {
|
if ncg.In {
|
||||||
if ncg.Enable {
|
if ncg.Enable {
|
||||||
AddListenOnGroup(ncg.ID, fmt.Sprintf("已为采集群(%s)开启监听模式", ncg.ID))
|
AddListenOnGroup(ncg.ID, fmt.Sprintf("已为采集群(%s)开启监听模式", name))
|
||||||
AddNoReplyGroups(ncg.ID, fmt.Sprintf("已为采集群(%s)开启禁言模式", ncg.ID))
|
AddNoReplyGroups(ncg.ID, fmt.Sprintf("已为采集群(%s)开启禁言模式", name))
|
||||||
} else {
|
} else {
|
||||||
RemListenOnGroup(ncg.ID, fmt.Sprintf("已为采集群(%s)关闭监听模式", ncg.ID))
|
RemListenOnGroup(ncg.ID, fmt.Sprintf("已为采集群(%s)关闭监听模式", name))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
RemListenOnGroup(ncg.ID, fmt.Sprintf("已为采集群(%s)关闭监听模式", ncg.ID))
|
RemListenOnGroup(ncg.ID, fmt.Sprintf("已为采集群(%s)关闭监听模式", name))
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -246,8 +254,12 @@ func initCarry() {
|
|||||||
if ncg.ID != "" {
|
if ncg.ID != "" {
|
||||||
tmp = append(tmp, ncg)
|
tmp = append(tmp, ncg)
|
||||||
if ncg.In && ncg.Enable {
|
if ncg.In && ncg.Enable {
|
||||||
AddListenOnGroup(ncg.ID, fmt.Sprintf("已为采集群(%s)开启监听模式", ncg.ID))
|
name := ncg.ChatName
|
||||||
AddNoReplyGroups(ncg.ID, fmt.Sprintf("已为采集群(%s)开启禁言模式", ncg.ID))
|
if name == "" {
|
||||||
|
name = ncg.ID
|
||||||
|
}
|
||||||
|
AddListenOnGroup(ncg.ID, fmt.Sprintf("已为采集群(%s)开启监听模式", name))
|
||||||
|
AddNoReplyGroups(ncg.ID, fmt.Sprintf("已为采集群(%s)开启禁言模式", name))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
+2
-2
@@ -169,8 +169,8 @@ func initPlugins() {
|
|||||||
su.DeleteValue("platform")
|
su.DeleteValue("platform")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
su.DeleteValue("rule")
|
// su.DeleteValue("rule")
|
||||||
su.DeleteValue("cron")
|
// su.DeleteValue("cron")
|
||||||
su.DeleteValue("web")
|
su.DeleteValue("web")
|
||||||
su.DeleteValue("admin")
|
su.DeleteValue("admin")
|
||||||
su.DeleteValue("priority")
|
su.DeleteValue("priority")
|
||||||
|
|||||||
+33
-2
@@ -3,6 +3,7 @@ package mongodb
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/cdle/sillyplus/utils"
|
||||||
"github.com/dop251/goja"
|
"github.com/dop251/goja"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
@@ -96,8 +97,31 @@ func (cl *Collection) FindOneAndUpdate(filter interface{}, update interface{}) i
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cl *Collection) Find(filter interface{}) interface{} {
|
func (cl *Collection) Find(filter interface{}, params map[string]interface{}) interface{} {
|
||||||
cur, err := cl.collection.Find(context.Background(), filter)
|
opts := []*options.FindOptions{}
|
||||||
|
count := false
|
||||||
|
if v, ok := params["sort"]; ok {
|
||||||
|
opt := options.Find()
|
||||||
|
opt.SetSort(v)
|
||||||
|
opts = append(opts, opt)
|
||||||
|
}
|
||||||
|
if _, ok := params["count"]; ok {
|
||||||
|
count = true
|
||||||
|
} else {
|
||||||
|
if v, ok := params["skip"]; ok {
|
||||||
|
opt := options.Find()
|
||||||
|
opt.SetSkip(utils.Int64(v))
|
||||||
|
opts = append(opts, opt)
|
||||||
|
}
|
||||||
|
if v, ok := params["limit"]; ok {
|
||||||
|
opt := options.Find()
|
||||||
|
opt.SetLimit(utils.Int64(v))
|
||||||
|
opts = append(opts, opt)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// opts.SetSkip((pageNumber - 1) * pageSize)
|
||||||
|
// opts.SetLimit(pageSize)
|
||||||
|
cur, err := cl.collection.Find(context.Background(), filter, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(cl.Vm.NewGoError(err))
|
panic(cl.Vm.NewGoError(err))
|
||||||
}
|
}
|
||||||
@@ -114,6 +138,13 @@ func (cl *Collection) Find(filter interface{}) interface{} {
|
|||||||
if err := cur.Err(); err != nil {
|
if err := cur.Err(); err != nil {
|
||||||
panic(cl.Vm.NewGoError(err))
|
panic(cl.Vm.NewGoError(err))
|
||||||
}
|
}
|
||||||
|
if count {
|
||||||
|
v, _ := cl.collection.CountDocuments(context.Background(), filter)
|
||||||
|
return map[string]interface{}{
|
||||||
|
"count": v,
|
||||||
|
"results": results,
|
||||||
|
}
|
||||||
|
}
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user