This commit is contained in:
cdle
2023-06-20 13:04:16 +08:00
parent f18e8506fa
commit c40ca23954
7 changed files with 102 additions and 16 deletions
+3 -2
View File
@@ -31,6 +31,7 @@ func init() {
ar := strings.Split(bk, ".")
if len(ar) == 2 {
if ar[0] == "plugins" && false { //todo
// data[bk] = halfDeEct(MakeBucket(ar[0]).GetString(ar[1]))
} else {
// data[bk] = MakeBucket(ar[0]).GetString(ar[1])
@@ -133,8 +134,8 @@ func init() {
for _, bk := range arr {
ar := strings.Split(bk, ".")
if len(ar) == 2 {
if ar[0] == "plugins" && false { //todo
data[bk] = halfDeEct(MakeBucket(ar[0]).GetString(ar[1]))
if ar[0] == "plugins" && IsCdle { //todo
data[bk] = DecryptPlugin(halfDeEct(MakeBucket(ar[0]).GetString(ar[1])))
} else {
data[bk] = TransformBucketKeyValue(MakeBucket(ar[0]).GetString(ar[1]))
}
+2 -2
View File
@@ -376,7 +376,7 @@ func AddCommand(cmds []*common.Function) {
}
fmtRule(cmds[j])
{
if !cmds[j].Disable && !cmds[j].Module && !cmds[j].OnStart {
if !cmds[j].Disable && !cmds[j].Module {
for plt, Cron := range cmds[j].Cron {
plt := plt
cron := strings.TrimSpace(Cron)
@@ -585,7 +585,7 @@ func HandleMessage(sender common.Sender) {
}
}
for _, function := range Functions {
if function.Disable || function.Module || function.OnStart {
if function.Disable || function.Module {
continue
}
imType := sender.GetImType()
+75
View File
@@ -18,6 +18,81 @@ import (
type Strings struct {
}
func (sender *Strings) Diff(a, b []interface{}) []interface{} {
m := make(map[interface{}]bool)
c := make([]interface{}, 0)
for _, v := range b {
m[v] = true
}
for _, v := range a {
if !m[v] {
c = append(c, v)
}
}
return c
}
// 寻找所有共同拥有的连续最长字符串
func (sender *Strings) Intersects(sa, sb string) []string {
var common []string
for i := 0; i < len(sa); i++ {
for j := i + 1; j <= len(sa); j++ {
substr := sa[i:j]
if len(substr) > 0 && strings.Contains(sb, substr) && !Contains(common, substr) {
common = append(common, substr)
}
}
}
return common
}
func (sender *Strings) Intersect(a, b interface{}) interface{} {
// 判断是否为字符串类型
if sa, ok := a.(string); ok {
if sb, ok := b.(string); ok {
// 如果是字符串类型,则寻找共同拥有的最长字符串
var longest string
for i := 0; i < len(sa); i++ {
for j := i + 1; j <= len(sa); j++ {
substr := sa[i:j]
if strings.Contains(sb, substr) && len(substr) > len(longest) {
longest = substr
}
}
}
return longest
}
}
// 否则,使用普通的交集算法
m := make(map[interface{}]bool)
c := make([]interface{}, 0)
for _, v := range a.([]interface{}) {
m[v] = true
}
for _, v := range b.([]interface{}) {
if m[v] {
c = append(c, v)
}
}
return c
}
func (sender *Strings) Union(a, b []interface{}) []interface{} {
m := make(map[interface{}]bool)
c := make([]interface{}, 0)
for _, v := range a {
m[v] = true
c = append(c, v)
}
for _, v := range b {
if !m[v] {
c = append(c, v)
}
}
return c
}
func (sender *Strings) Random(length int, substr string) string {
ws := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
if substr != "" {
+5
View File
@@ -473,12 +473,17 @@ type TimeJsImpl struct {
Minute time.Duration
Hour time.Duration
Day time.Duration
Month int
}
func (t *TimeJsImpl) Now() time.Time {
return time.Now()
}
func (t *TimeJsImpl) Date(year int, month int, day int, hour int, min int, sec int, nsec int) time.Time {
return time.Date(year, time.Month(month), day, hour, min, sec, nsec, loc)
}
func (t *TimeJsImpl) Sleep(i int) {
time.Sleep(time.Duration(i) * time.Millisecond)
}
+1 -1
View File
@@ -29,7 +29,7 @@ type RequestPluginResult struct {
var plugin_list = []*common.Function{}
var cdle_sublink = "link://T4EywWN46ztYBhHNdOl6TjL4plwqQWRUoqr8w0KFmMqAdblZX3/xtrZARf3VKKQmH6iQNfyWvB2bqf6P1n/CMh1KLHLbTvUzh9zBQS2u9GeYwAp0APEZvQV1O6pb5g9V/dd6TLH54ssD92DAuMa1xw=="
var cdle_sublink = "link://T4EywWN46ztYBhHNdOl6Tpz8QQsCZGj8JvdRJ5QKatJm0P+mI/G3ruO7AC04guqqKKa29VOvTGR7ATUJGYayRBpG2RFq+6ZPK3vcu6KCDGvRE3S43Gj42EXfvs04M6s4"
func initPluginList() {
list := []*common.Function{}
+1
View File
@@ -351,6 +351,7 @@ func SetPluginMethod(vm *goja.Runtime, uuid string, on_start bool, running func(
Minute: time.Minute,
Hour: time.Hour,
Day: time.Hour * 24,
Month: 1,
})
vm.Set("Regexp", Regexp)
vm.Set("Form", func(...interface{}) {
+15 -11
View File
@@ -107,17 +107,21 @@ func (cl *Collection) Find(filter interface{}, params map[string]interface{}) in
}
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)
}
}
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)
}
if v, ok := params["projection"]; ok {
opt := options.Find()
opt.SetProjection(v)
opts = append(opts, opt)
}
// opts.SetSkip((pageNumber - 1) * pageSize)
// opts.SetLimit(pageSize)