This commit is contained in:
cdle
2021-10-08 11:42:15 +08:00
parent de57bcb254
commit cbb16963e4
2 changed files with 35 additions and 13 deletions
+2 -1
View File
@@ -11,4 +11,5 @@ jd_*
data
dwz
replies
qinglongs
qinglongs
sets.conf
+33 -12
View File
@@ -1,6 +1,12 @@
package core
import "regexp"
import (
"regexp"
"strings"
"sync"
"github.com/beego/beego/v2/adapter/httplib"
)
var Pushs = map[string]func(int, string){}
var GroupPushs = map[string]func(int, int, string){}
@@ -30,19 +36,34 @@ func (ct *Chat) Push(content interface{}) {
}
}
var notLock sync.Locker
var msgs = map[string]string{}
func NotifyMasters(content string) {
if sillyGirl.GetBool("ignore_notify", false) == true {
return
}
for _, class := range []string{"tg", "qq"} {
notify := Bucket(class).Get("notifiers")
if notify == "" {
notify = Bucket(class).Get("masters")
go func() {
content = strings.Trim(content, " ")
notLock.Lock()
defer notLock.Unlock()
if _, ok := msgs[content]; ok {
return
}
for _, v := range regexp.MustCompile(`(\d+)`).FindAllStringSubmatch(notify, -1) {
if push, ok := Pushs[class]; ok {
push(Int(v[1]), content)
msgs[content] = ""
if sillyGirl.GetBool("ignore_notify", false) == true {
return
}
if token := sillyGirl.Get("pushplus"); token != "" {
httplib.Get("http://www.pushplus.plus/send?token=" + token + "&title=0101010&content=" + content + "&template=html")
}
for _, class := range []string{"tg", "qq"} {
notify := Bucket(class).Get("notifiers")
if notify == "" {
notify = Bucket(class).Get("masters")
}
for _, v := range regexp.MustCompile(`(\d+)`).FindAllStringSubmatch(notify, -1) {
if push, ok := Pushs[class]; ok {
push(Int(v[1]), content)
}
}
}
}
}()
}