diff --git a/core/carry.go b/core/carry.go index 8547aef..1c09600 100644 --- a/core/carry.go +++ b/core/carry.go @@ -379,7 +379,7 @@ func init() { var scripts = map[string]string{} functions := Functions for _, function := range functions { - if function.UUID != "" && len(function.Rules) == 0 && !function.OnStart && !function.Module && function.Http == nil && function.Reply == nil { + if function.UUID != "" && ((len(function.Rules) == 0 && !function.OnStart && !function.Module && function.Http == nil && function.Reply == nil) || function.Carry) { scripts[function.UUID] = function.Title + ".js" } } diff --git a/core/common/function.go b/core/common/function.go index 2712dee..5b5b121 100644 --- a/core/common/function.go +++ b/core/common/function.go @@ -37,6 +37,7 @@ type Function struct { Reply *Reply `json:"-"` Downloads int `json:"downloads"` HasForm bool `json:"has_form"` + Carry bool `json:"carry"` } type Filter struct { BlackMode bool diff --git a/core/node_bucket.go b/core/node_bucket.go index 02891ba..ce72042 100644 --- a/core/node_bucket.go +++ b/core/node_bucket.go @@ -10,7 +10,7 @@ func MakeBucketObject(vm *goja.Runtime, uuid string, on_start bool, bucket stora obj.Set("get", func(v ...interface{}) interface{} { return GetBucketKeyValue(bucket, v...) }) - obj.Set("foreach", func(v ...interface{}) map[string]interface{} { + obj.Set("getAll", func(v ...interface{}) map[string]interface{} { var rt = map[string]interface{}{} bucket.Foreach(func(b1, b2 []byte) error { rt[string(b1)] = TransformBucketKeyValue(string(b2)) diff --git a/core/node_strings.go b/core/node_strings.go index 0955810..aff3267 100644 --- a/core/node_strings.go +++ b/core/node_strings.go @@ -122,6 +122,10 @@ func (sender *Strings) ToUpper(s string) string { func (sender *Strings) Remove(ss []string, s string) []string { return utils.Remove(ss, s) } + +func (sender *Strings) Append(ss []string, s string) []string { + return append(ss, s) +} func (sender *Strings) HasPrefix(s, substr string) bool { return strings.HasPrefix(s, substr) } @@ -129,11 +133,29 @@ func (sender *Strings) HasSuffix(s, substr string) bool { return strings.HasSuffix(s, substr) } -func (sender *Strings) Replace(s string, old string, new string, n int) string { - if n == 0 { - n = -1 +func (sender *Strings) Replace(s_ interface{}, old string, new string, n int) interface{} { + switch s := s_.(type) { + case string: + if n == 0 { + n = -1 + } + return strings.Replace(s, old, new, n) + case []string: + for i := range s { + if s[i] == old { + s[i] = new + } + } + return s + case []interface{}: + for i := range s { + if s[i] == old { + s[i] = new + } + } + return s } - return strings.Replace(s, old, new, n) + return "" } func (sender *Strings) ReplaceAll(s string, old string, new string) string { diff --git a/core/plugin_core.go b/core/plugin_core.go index 4dccf52..aa84568 100644 --- a/core/plugin_core.go +++ b/core/plugin_core.go @@ -264,6 +264,7 @@ func initPlugin(data string, uuid string) (*common.Function, error) { var message *common.Reply var FindAll bool var hasForm bool + var carry bool ress := regexp.MustCompile( `\*\s?@([\d\w+-]+)\s+([^\n]+?)\n`, ).FindAllStringSubmatch(data, -1) @@ -423,6 +424,8 @@ func initPlugin(data string, uuid string) (*common.Function, error) { module = strings.TrimSpace(res[2]) == "true" case "web": web = strings.TrimSpace(res[2]) == "true" + case "carry": + carry = strings.TrimSpace(res[2]) == "true" case "encrypt": encrypt = strings.TrimSpace(res[2]) == "true" case "on_start": @@ -566,6 +569,7 @@ func initPlugin(data string, uuid string) (*common.Function, error) { Http: http, FindAll: FindAll, HasForm: hasForm, + Carry: carry, } running = func() bool { return f.Running