x
This commit is contained in:
+1
-1
@@ -379,7 +379,7 @@ func init() {
|
|||||||
var scripts = map[string]string{}
|
var scripts = map[string]string{}
|
||||||
functions := Functions
|
functions := Functions
|
||||||
for _, function := range 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"
|
scripts[function.UUID] = function.Title + ".js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ type Function struct {
|
|||||||
Reply *Reply `json:"-"`
|
Reply *Reply `json:"-"`
|
||||||
Downloads int `json:"downloads"`
|
Downloads int `json:"downloads"`
|
||||||
HasForm bool `json:"has_form"`
|
HasForm bool `json:"has_form"`
|
||||||
|
Carry bool `json:"carry"`
|
||||||
}
|
}
|
||||||
type Filter struct {
|
type Filter struct {
|
||||||
BlackMode bool
|
BlackMode bool
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ func MakeBucketObject(vm *goja.Runtime, uuid string, on_start bool, bucket stora
|
|||||||
obj.Set("get", func(v ...interface{}) interface{} {
|
obj.Set("get", func(v ...interface{}) interface{} {
|
||||||
return GetBucketKeyValue(bucket, v...)
|
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{}{}
|
var rt = map[string]interface{}{}
|
||||||
bucket.Foreach(func(b1, b2 []byte) error {
|
bucket.Foreach(func(b1, b2 []byte) error {
|
||||||
rt[string(b1)] = TransformBucketKeyValue(string(b2))
|
rt[string(b1)] = TransformBucketKeyValue(string(b2))
|
||||||
|
|||||||
+26
-4
@@ -122,6 +122,10 @@ func (sender *Strings) ToUpper(s string) string {
|
|||||||
func (sender *Strings) Remove(ss []string, s string) []string {
|
func (sender *Strings) Remove(ss []string, s string) []string {
|
||||||
return utils.Remove(ss, s)
|
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 {
|
func (sender *Strings) HasPrefix(s, substr string) bool {
|
||||||
return strings.HasPrefix(s, substr)
|
return strings.HasPrefix(s, substr)
|
||||||
}
|
}
|
||||||
@@ -129,11 +133,29 @@ func (sender *Strings) HasSuffix(s, substr string) bool {
|
|||||||
return strings.HasSuffix(s, substr)
|
return strings.HasSuffix(s, substr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sender *Strings) Replace(s string, old string, new string, n int) string {
|
func (sender *Strings) Replace(s_ interface{}, old string, new string, n int) interface{} {
|
||||||
if n == 0 {
|
switch s := s_.(type) {
|
||||||
n = -1
|
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 {
|
func (sender *Strings) ReplaceAll(s string, old string, new string) string {
|
||||||
|
|||||||
@@ -264,6 +264,7 @@ func initPlugin(data string, uuid string) (*common.Function, error) {
|
|||||||
var message *common.Reply
|
var message *common.Reply
|
||||||
var FindAll bool
|
var FindAll bool
|
||||||
var hasForm bool
|
var hasForm bool
|
||||||
|
var carry bool
|
||||||
ress := regexp.MustCompile(
|
ress := regexp.MustCompile(
|
||||||
`\*\s?@([\d\w+-]+)\s+([^\n]+?)\n`,
|
`\*\s?@([\d\w+-]+)\s+([^\n]+?)\n`,
|
||||||
).FindAllStringSubmatch(data, -1)
|
).FindAllStringSubmatch(data, -1)
|
||||||
@@ -423,6 +424,8 @@ func initPlugin(data string, uuid string) (*common.Function, error) {
|
|||||||
module = strings.TrimSpace(res[2]) == "true"
|
module = strings.TrimSpace(res[2]) == "true"
|
||||||
case "web":
|
case "web":
|
||||||
web = strings.TrimSpace(res[2]) == "true"
|
web = strings.TrimSpace(res[2]) == "true"
|
||||||
|
case "carry":
|
||||||
|
carry = strings.TrimSpace(res[2]) == "true"
|
||||||
case "encrypt":
|
case "encrypt":
|
||||||
encrypt = strings.TrimSpace(res[2]) == "true"
|
encrypt = strings.TrimSpace(res[2]) == "true"
|
||||||
case "on_start":
|
case "on_start":
|
||||||
@@ -566,6 +569,7 @@ func initPlugin(data string, uuid string) (*common.Function, error) {
|
|||||||
Http: http,
|
Http: http,
|
||||||
FindAll: FindAll,
|
FindAll: FindAll,
|
||||||
HasForm: hasForm,
|
HasForm: hasForm,
|
||||||
|
Carry: carry,
|
||||||
}
|
}
|
||||||
running = func() bool {
|
running = func() bool {
|
||||||
return f.Running
|
return f.Running
|
||||||
|
|||||||
Reference in New Issue
Block a user