Merge branch 'cdle:main' into main

This commit is contained in:
xumf
2021-10-13 14:10:22 +08:00
committed by GitHub
5 changed files with 21 additions and 13 deletions
+1 -1
View File
@@ -132,7 +132,7 @@ set wxmp masters w1&w2&w3...
#set wx relay_mode true
##### 设置指定转发地址,格式为 https://域名/reply?url=%s
##### 设置指定转发地址,格式为 https://域名/relay?url=%s
#set wx relaier ?
+3 -3
View File
@@ -111,9 +111,9 @@ func handleMessage(sender Sender) {
if function.Admin && !sender.IsAdmin() {
sender.Delete()
sender.Disappear()
if sender.GetImType() != "wx" && sender.GetImType() != "qq" {
sender.Reply("没有权限操作")
}
// if sender.GetImType() != "wx" && sender.GetImType() != "qq" {
sender.Reply("再捣乱我就报警啦~")
// }
sender.Finish()
return
}
+11 -6
View File
@@ -246,7 +246,7 @@ func start() {
}
}
OnGroupMessage := func(_ *client.QQClient, m *message.GroupMessage) {
if ignore := qq.Get("offGroups", "654346133"); strings.Contains(ignore, fmt.Sprint(m.GroupCode)) {
if ignore := qq.Get("offGroups", "654346133&923993867"); strings.Contains(ignore, fmt.Sprint(m.GroupCode)) {
return
}
if listen := qq.Get("onGroups"); listen != "" && !strings.Contains(listen, fmt.Sprint(m.GroupCode)) {
@@ -259,11 +259,16 @@ func start() {
bot.Client.OnPrivateMessage(onPrivateMessage)
bot.Client.OnGroupMessage(OnGroupMessage)
bot.Client.OnTempMessage(onTempMessage)
if qq.GetBool("onself", true) == true {
bot.Client.OnSelfPrivateMessage(onPrivateMessage)
bot.Client.OnSelfGroupMessage(OnGroupMessage)
}
bot.Client.OnSelfPrivateMessage(func(q *client.QQClient, pm *message.PrivateMessage) {
if qq.GetBool("onself", true) == true {
onPrivateMessage(q, pm)
}
})
bot.Client.OnSelfGroupMessage(func(q *client.QQClient, gm *message.GroupMessage) {
if qq.GetBool("onself", true) == true {
OnGroupMessage(q, gm)
}
})
bot.Client.OnNewFriendRequest(func(_ *client.QQClient, request *client.NewFriendRequest) {
if qq.GetBool("auto_friend", false) == true {
time.Sleep(time.Second)
+1
View File
@@ -34,6 +34,7 @@ func (sender *Sender) GetContent() string {
text = strings.Replace(text, "amp;", "", -1)
text = strings.Replace(text, "[", "[", -1)
text = strings.Replace(text, "]", "]", -1)
// sender.Reply(text)
// text = regexp.MustCompile(`]`).ReplaceAllString(text, "")
return text
}
+5 -3
View File
@@ -17,7 +17,9 @@ import (
)
var wx = core.NewBucket("wx")
var api_url = wx.Get("api_url")
var api_url = func() string {
return wx.Get("api_url")
}
var robot_wxid = wx.Get("robot_wxid")
func sendTextMsg(pmsg *TextMsg) {
@@ -27,7 +29,7 @@ func sendTextMsg(pmsg *TextMsg) {
}
pmsg.Event = "SendTextMsg"
pmsg.RobotWxid = robot_wxid
req := httplib.Post(api_url)
req := httplib.Post(api_url())
req.Header("Content-Type", "application/json")
data, _ := json.Marshal(pmsg)
enc := mahonia.NewEncoder("gbk")
@@ -57,7 +59,7 @@ func sendOtherMsg(pmsg *OtherMsg) {
pmsg.Event = "SendImageMsg"
}
pmsg.RobotWxid = robot_wxid
req := httplib.Post(api_url)
req := httplib.Post(api_url())
req.Header("Content-Type", "application/json")
data, _ := json.Marshal(pmsg)
req.Body(data)