From e3a5d0f71f500d9551c373ee01991a29b229a70b Mon Sep 17 00:00:00 2001 From: cdle <798731886@qq.com> Date: Wed, 13 Oct 2021 10:37:22 +0800 Subject: [PATCH 1/5] update --- README.md | 2 +- im/wx/init.go | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b57e834..7b6dd68 100644 --- a/README.md +++ b/README.md @@ -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 ? diff --git a/im/wx/init.go b/im/wx/init.go index 9c7edec..ec0d75b 100644 --- a/im/wx/init.go +++ b/im/wx/init.go @@ -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) From e0cb003253c1e9c7c8f361588994e91abb48d147 Mon Sep 17 00:00:00 2001 From: cdle <798731886@qq.com> Date: Wed, 13 Oct 2021 10:57:04 +0800 Subject: [PATCH 2/5] update --- core/function.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/function.go b/core/function.go index 3ead126..67660ae 100644 --- a/core/function.go +++ b/core/function.go @@ -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 } From 71971840f4384d40fa58807c2fd86f96a956d516 Mon Sep 17 00:00:00 2001 From: cdle <798731886@qq.com> Date: Wed, 13 Oct 2021 11:23:12 +0800 Subject: [PATCH 3/5] update --- im/qq/sender.go | 1 + 1 file changed, 1 insertion(+) diff --git a/im/qq/sender.go b/im/qq/sender.go index 6e6bbdb..d0f6e41 100644 --- a/im/qq/sender.go +++ b/im/qq/sender.go @@ -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 } From e2a92aab88f9a6f5342ed8562f2cbdd8658b329b Mon Sep 17 00:00:00 2001 From: cdle <798731886@qq.com> Date: Wed, 13 Oct 2021 11:26:31 +0800 Subject: [PATCH 4/5] update --- im/qq/sender.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/im/qq/sender.go b/im/qq/sender.go index d0f6e41..539bbf6 100644 --- a/im/qq/sender.go +++ b/im/qq/sender.go @@ -34,7 +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) + // sender.Reply(text) // text = regexp.MustCompile(`]`).ReplaceAllString(text, "") return text } From 674c1ae070860e85bca4decf97c4b22ceb1412d6 Mon Sep 17 00:00:00 2001 From: cdle <798731886@qq.com> Date: Wed, 13 Oct 2021 13:04:12 +0800 Subject: [PATCH 5/5] update --- im/qq/main.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/im/qq/main.go b/im/qq/main.go index 9ed06c9..ce3b1c5 100644 --- a/im/qq/main.go +++ b/im/qq/main.go @@ -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)