x
This commit is contained in:
@@ -8,6 +8,6 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<script src="/admin/umi.99c0f090.js"></script>
|
<script src="/admin/umi.7c524e1b.js"></script>
|
||||||
|
|
||||||
</body></html>
|
</body></html>
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+7
-3
@@ -269,9 +269,13 @@ func setCgs() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if cg.In {
|
if cg.In && cg.Enable {
|
||||||
AddListenOnGroup(cg.ID, fmt.Sprintf("已为采集群(%s)开启监听模式", cg.ID))
|
name := cg.ChatName
|
||||||
AddNoReplyGroups(cg.ID, fmt.Sprintf("已为采集群(%s)开启禁言模式", cg.ID))
|
if name == "" {
|
||||||
|
name = cg.ID
|
||||||
|
}
|
||||||
|
AddListenOnGroup(cg.ID, fmt.Sprintf("已为采集群(%s)开启监听模式", name))
|
||||||
|
AddNoReplyGroups(cg.ID, fmt.Sprintf("已为采集群(%s)开启禁言模式", name))
|
||||||
}
|
}
|
||||||
cgs = append(cgs, cg)
|
cgs = append(cgs, cg)
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ type Function struct {
|
|||||||
FindAll bool `json:"-"`
|
FindAll bool `json:"-"`
|
||||||
Admin bool `json:"-"`
|
Admin bool `json:"-"`
|
||||||
Handle func(Sender, func(vm *goja.Runtime)) interface{} `json:"-"`
|
Handle func(Sender, func(vm *goja.Runtime)) interface{} `json:"-"`
|
||||||
Cron string `json:"cron"`
|
Cron map[string]string `json:"cron"`
|
||||||
Priority int `json:"-"`
|
Priority int `json:"-"`
|
||||||
Disable bool `json:"-"`
|
Disable bool `json:"-"`
|
||||||
Hidden bool `json:"-"`
|
Hidden bool `json:"-"`
|
||||||
CronId int `json:"-"`
|
CronIds []int `json:"-"`
|
||||||
Origin string `json:"-"`
|
Origin string `json:"-"`
|
||||||
UUID string `json:"id"`
|
UUID string `json:"id"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
|
|||||||
+12
-6
@@ -376,25 +376,31 @@ func AddCommand(cmds []*common.Function) {
|
|||||||
}
|
}
|
||||||
fmtRule(cmds[j])
|
fmtRule(cmds[j])
|
||||||
{
|
{
|
||||||
if cmds[j].Cron != "" && !cmds[j].Disable && !cmds[j].Module && !cmds[j].OnStart {
|
if !cmds[j].Disable && !cmds[j].Module && !cmds[j].OnStart {
|
||||||
cron := strings.TrimSpace(cmds[j].Cron)
|
for plt, Cron := range cmds[j].Cron {
|
||||||
|
plt := plt
|
||||||
|
cron := strings.TrimSpace(Cron)
|
||||||
if len(regexp.MustCompile(`\S+`).FindAllString(cron, -1)) == 5 {
|
if len(regexp.MustCompile(`\S+`).FindAllString(cron, -1)) == 5 {
|
||||||
cmds[j].Cron = "0 " + cron
|
Cron = "0 " + Cron
|
||||||
}
|
}
|
||||||
cronId, err := C.AddFunc(cmds[j].Cron, func() {
|
cronId, err := C.AddFunc(Cron, func() {
|
||||||
cmds[j].Handle(&Faker{
|
cmds[j].Handle(&Faker{
|
||||||
Admin: true,
|
Admin: true,
|
||||||
Type: "cron",
|
Type: plt,
|
||||||
}, nil)
|
}, nil)
|
||||||
})
|
})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
cmds[j].CronId = int(cronId)
|
cmds[j].CronIds = append(cmds[j].CronIds, int(cronId))
|
||||||
// console["log"]("脚本%s添加定时器", cmds[j].Title)
|
// console["log"]("脚本%s添加定时器", cmds[j].Title)
|
||||||
} else {
|
} else {
|
||||||
console.Error("脚本%s定时器错误,%v", cmds[j].Title, err)
|
console.Error("脚本%s定时器错误,%v", cmds[j].Title, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// if cmds[j].Cron != "" && !cmds[j].Disable && !cmds[j].Module && !cmds[j].OnStart {
|
||||||
|
|
||||||
|
// }
|
||||||
|
}
|
||||||
{
|
{
|
||||||
lf := len(Functions)
|
lf := len(Functions)
|
||||||
for i := range Functions {
|
for i := range Functions {
|
||||||
|
|||||||
@@ -90,9 +90,7 @@ func (sender *Strings) Dir(path string) string {
|
|||||||
func (sender *Strings) Contains(s string, substr interface{}) bool {
|
func (sender *Strings) Contains(s string, substr interface{}) bool {
|
||||||
switch substr := substr.(type) {
|
switch substr := substr.(type) {
|
||||||
case string:
|
case string:
|
||||||
if strings.Contains(s, substr) {
|
return strings.Contains(s, substr)
|
||||||
return true
|
|
||||||
}
|
|
||||||
case []string:
|
case []string:
|
||||||
for _, sub := range substr {
|
for _, sub := range substr {
|
||||||
if strings.Contains(s, sub) {
|
if strings.Contains(s, sub) {
|
||||||
@@ -166,6 +164,10 @@ func (sender *Strings) Split(s string, sep string, n int) []string {
|
|||||||
return strings.SplitN(s, sep, n)
|
return strings.SplitN(s, sep, n)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sender *Strings) BuildQuery(params map[string]interface{}) string {
|
||||||
|
return sender.EncodeQueryString(params)
|
||||||
|
}
|
||||||
|
|
||||||
func (sender *Strings) EncodeQueryString(params map[string]interface{}) string {
|
func (sender *Strings) EncodeQueryString(params map[string]interface{}) string {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
for key, value := range params {
|
for key, value := range params {
|
||||||
@@ -192,6 +194,10 @@ func (sender *Strings) EncodeQueryString(params map[string]interface{}) string {
|
|||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sender *Strings) ParseQuery(querystring string) map[string]interface{} {
|
||||||
|
return sender.DecodeQueryString(querystring)
|
||||||
|
}
|
||||||
|
|
||||||
func (sender *Strings) DecodeQueryString(querystring string) map[string]interface{} {
|
func (sender *Strings) DecodeQueryString(querystring string) map[string]interface{} {
|
||||||
u, err := url.Parse(querystring)
|
u, err := url.Parse(querystring)
|
||||||
|
|
||||||
|
|||||||
+14
-10
@@ -199,9 +199,10 @@ func initPlugins() {
|
|||||||
if Functions[i].UUID == key {
|
if Functions[i].UUID == key {
|
||||||
DestroyAdapterByUUID(key)
|
DestroyAdapterByUUID(key)
|
||||||
Functions[i].Running = false
|
Functions[i].Running = false
|
||||||
if Functions[i].CronId != 0 {
|
if len(Functions[i].CronIds) != 0 {
|
||||||
C.Remove(cron.EntryID(Functions[i].CronId))
|
for _, id := range Functions[i].CronIds {
|
||||||
|
C.Remove(cron.EntryID(id))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Functions = append(Functions[:i], Functions[i+1:]...)
|
Functions = append(Functions[:i], Functions[i+1:]...)
|
||||||
CancelPluginCrons(key)
|
CancelPluginCrons(key)
|
||||||
@@ -244,7 +245,7 @@ func initPlugin(data string, uuid string) (*common.Function, error) {
|
|||||||
var imType *common.Filter
|
var imType *common.Filter
|
||||||
var userId *common.Filter
|
var userId *common.Filter
|
||||||
var groupId *common.Filter
|
var groupId *common.Filter
|
||||||
var cron string
|
var cron = map[string]string{}
|
||||||
var admin bool
|
var admin bool
|
||||||
var disable bool
|
var disable bool
|
||||||
var priority int
|
var priority int
|
||||||
@@ -365,9 +366,6 @@ func initPlugin(data string, uuid string) (*common.Function, error) {
|
|||||||
BlackMode: true,
|
BlackMode: true,
|
||||||
Items: item,
|
Items: item,
|
||||||
}
|
}
|
||||||
case "cron", "crontab":
|
|
||||||
cron = strings.TrimSpace(res[2])
|
|
||||||
cron = strings.ReplaceAll(cron, `\/`, "/")
|
|
||||||
case "admin":
|
case "admin":
|
||||||
admin = strings.TrimSpace(res[2]) == "true"
|
admin = strings.TrimSpace(res[2]) == "true"
|
||||||
case "disable":
|
case "disable":
|
||||||
@@ -438,6 +436,12 @@ func initPlugin(data string, uuid string) (*common.Function, error) {
|
|||||||
time.Sleep(time.Second * 2)
|
time.Sleep(time.Second * 2)
|
||||||
getPaterner(uuid, strings.TrimSpace(paterner))
|
getPaterner(uuid, strings.TrimSpace(paterner))
|
||||||
}()
|
}()
|
||||||
|
default:
|
||||||
|
cron_ := strings.TrimSpace(res[2])
|
||||||
|
cron_ = strings.ReplaceAll(cron_, `\/`, "/")
|
||||||
|
if strings.HasPrefix(res[1], "cron") {
|
||||||
|
cron[res[1]] = cron_
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
script := ""
|
script := ""
|
||||||
@@ -453,9 +457,9 @@ func initPlugin(data string, uuid string) (*common.Function, error) {
|
|||||||
if err == nil && err2 != nil {
|
if err == nil && err2 != nil {
|
||||||
err = err2
|
err = err2
|
||||||
}
|
}
|
||||||
if err == nil && len(rules) == 0 && cron != "" {
|
// if err == nil && len(rules) == 0 && cron != "" {
|
||||||
err = fmt.Errorf("无效的脚本%s", title)
|
// err = fmt.Errorf("无效的脚本%s", title)
|
||||||
}
|
// }
|
||||||
if web {
|
if web {
|
||||||
onStart = true
|
onStart = true
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-11
@@ -260,20 +260,29 @@ func (sender *SenderJsIplm) IsAdmin() bool {
|
|||||||
return sender.Message.IsAdmin()
|
return sender.Message.IsAdmin()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sender *SenderJsIplm) Reply(text string) *goja.Promise {
|
func (sender *SenderJsIplm) Reply(text string) interface{} {
|
||||||
promise, resolve, reject := sender.Vm.NewPromise()
|
// promise, resolve, reject := sender.Vm.NewPromise()
|
||||||
go func() {
|
// go func() {
|
||||||
if text == "" {
|
// defer func() {
|
||||||
resolve("")
|
// recover()
|
||||||
return
|
// }()
|
||||||
}
|
// if text == "" {
|
||||||
|
// resolve("")
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// i, err := sender.Message.Reply(text)
|
||||||
|
// if err != nil {
|
||||||
|
// reject(err.Error())
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// resolve(i)
|
||||||
|
// }()
|
||||||
|
// return promise
|
||||||
i, err := sender.Message.Reply(text)
|
i, err := sender.Message.Reply(text)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reject(err.Error())
|
panic(Error(sender.Vm, err))
|
||||||
}
|
}
|
||||||
resolve(i)
|
return i
|
||||||
}()
|
|
||||||
return promise
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sender *SenderJsIplm) HoldOn(str ...string) string {
|
func (sender *SenderJsIplm) HoldOn(str ...string) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user