update
This commit is contained in:
+2
-1
@@ -11,4 +11,5 @@ jd_*
|
||||
data
|
||||
dwz
|
||||
replies
|
||||
qinglongs
|
||||
qinglongs
|
||||
sets.conf
|
||||
+33
-12
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user