x
This commit is contained in:
+1
-1
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
+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{} {
|
||||
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))
|
||||
|
||||
+26
-4
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user