update
This commit is contained in:
@@ -12,3 +12,4 @@ data
|
|||||||
dwz
|
dwz
|
||||||
replies
|
replies
|
||||||
qinglongs
|
qinglongs
|
||||||
|
sets.conf
|
||||||
+33
-12
@@ -1,6 +1,12 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
import "regexp"
|
import (
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/beego/beego/v2/adapter/httplib"
|
||||||
|
)
|
||||||
|
|
||||||
var Pushs = map[string]func(int, string){}
|
var Pushs = map[string]func(int, string){}
|
||||||
var GroupPushs = map[string]func(int, 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) {
|
func NotifyMasters(content string) {
|
||||||
if sillyGirl.GetBool("ignore_notify", false) == true {
|
go func() {
|
||||||
return
|
content = strings.Trim(content, " ")
|
||||||
}
|
notLock.Lock()
|
||||||
for _, class := range []string{"tg", "qq"} {
|
defer notLock.Unlock()
|
||||||
notify := Bucket(class).Get("notifiers")
|
if _, ok := msgs[content]; ok {
|
||||||
if notify == "" {
|
return
|
||||||
notify = Bucket(class).Get("masters")
|
|
||||||
}
|
}
|
||||||
for _, v := range regexp.MustCompile(`(\d+)`).FindAllStringSubmatch(notify, -1) {
|
msgs[content] = ""
|
||||||
if push, ok := Pushs[class]; ok {
|
if sillyGirl.GetBool("ignore_notify", false) == true {
|
||||||
push(Int(v[1]), content)
|
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