From 8fc242b79457ec66727b1ff9344585e2393266ae Mon Sep 17 00:00:00 2001 From: eatmoreapple Date: Fri, 18 Nov 2022 17:32:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20receiver=20=E4=B8=BA=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BC=A0=E8=BE=93=E5=8A=A9=E6=89=8B=E7=9A=84?= =?UTF-8?q?=E6=97=B6,=20receiver=20=E6=89=BE=E4=B8=8D=E5=88=B0=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- message.go | 8 +++++--- test.json | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 test.json diff --git a/message.go b/message.go index be2992f..dcefb88 100644 --- a/message.go +++ b/message.go @@ -105,9 +105,13 @@ func (m *Message) SenderInGroup() (*User, error) { // 如果消息是好友消息,则返回好友 // 如果消息是系统消息,则返回当前用户 func (m *Message) Receiver() (*User, error) { - if m.IsSystem() { + if m.IsSystem() || m.ToUserName == m.Bot.self.UserName { return m.Bot.self.User, nil } + // https://github.com/eatmoreapple/openwechat/issues/113 + if m.ToUserName == m.Bot.self.fileHelper.UserName { + return m.Bot.self.fileHelper.User, nil + } if m.IsSendByGroup() { groups, err := m.Bot.self.Groups() if err != nil { @@ -122,8 +126,6 @@ func (m *Message) Receiver() (*User, error) { return nil, ErrNoSuchUserFoundError } return users.First().User, nil - } else if m.ToUserName == m.Bot.self.UserName { - return m.Bot.self.User, nil } else { user, exist := m.Bot.self.MemberList.GetByRemarkName(m.ToUserName) if !exist { diff --git a/test.json b/test.json new file mode 100644 index 0000000..a8e333d --- /dev/null +++ b/test.json @@ -0,0 +1 @@ +{"Cookies":{"https://login.wx.qq.com/cgi-bin/mmwebwx-bin/login":[],"https://login.wx.qq.com/jslogin":[],"https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage":[{"Name":"wxuin","Value":"164265249","Path":"/","Domain":"wx2.qq.com","Expires":"2022-11-17T13:59:05Z","RawExpires":"Thu, 17-Nov-2022 13:59:05 GMT","MaxAge":0,"Secure":true,"HttpOnly":false,"SameSite":0,"Raw":"wxuin=164265249; Domain=wx2.qq.com; Path=/; Expires=Thu, 17-Nov-2022 13:59:05 GMT; Secure","Unparsed":null},{"Name":"wxsid","Value":"lhh0FVX8Vjwir/2A","Path":"/","Domain":"wx2.qq.com","Expires":"2022-11-17T13:59:05Z","RawExpires":"Thu, 17-Nov-2022 13:59:05 GMT","MaxAge":0,"Secure":true,"HttpOnly":false,"SameSite":0,"Raw":"wxsid=lhh0FVX8Vjwir/2A; Domain=wx2.qq.com; Path=/; Expires=Thu, 17-Nov-2022 13:59:05 GMT; Secure","Unparsed":null},{"Name":"wxloadtime","Value":"1668650345","Path":"/","Domain":"wx2.qq.com","Expires":"2022-11-17T13:59:05Z","RawExpires":"Thu, 17-Nov-2022 13:59:05 GMT","MaxAge":0,"Secure":true,"HttpOnly":false,"SameSite":0,"Raw":"wxloadtime=1668650345; Domain=wx2.qq.com; Path=/; Expires=Thu, 17-Nov-2022 13:59:05 GMT; Secure","Unparsed":null},{"Name":"mm_lang","Value":"zh_CN","Path":"/","Domain":"wx2.qq.com","Expires":"2022-11-17T13:59:05Z","RawExpires":"Thu, 17-Nov-2022 13:59:05 GMT","MaxAge":0,"Secure":true,"HttpOnly":false,"SameSite":0,"Raw":"mm_lang=zh_CN; Domain=wx2.qq.com; Path=/; Expires=Thu, 17-Nov-2022 13:59:05 GMT; Secure","Unparsed":null},{"Name":"wxuin","Value":"164265249","Path":"/","Domain":".qq.com","Expires":"2022-11-17T13:59:05Z","RawExpires":"Thu, 17-Nov-2022 13:59:05 GMT","MaxAge":0,"Secure":true,"HttpOnly":false,"SameSite":0,"Raw":"wxuin=164265249; Domain=.qq.com; Path=/; Expires=Thu, 17-Nov-2022 13:59:05 GMT; Secure","Unparsed":null},{"Name":"webwx_data_ticket","Value":"gSdSjeQ+w4IHWFN1T0cCBbXP","Path":"/","Domain":".qq.com","Expires":"2022-11-17T13:59:05Z","RawExpires":"Thu, 17-Nov-2022 13:59:05 GMT","MaxAge":0,"Secure":true,"HttpOnly":false,"SameSite":0,"Raw":"webwx_data_ticket=gSdSjeQ+w4IHWFN1T0cCBbXP; Domain=.qq.com; Path=/; Expires=Thu, 17-Nov-2022 13:59:05 GMT; Secure","Unparsed":null},{"Name":"webwxuvid","Value":"b2ff8fe2430e13c57b78ee4cf4bc2aaaca7398f8aac7c3fae61d872bf1f5b1793bb86d87f6363d773112907853f5a06f","Path":"/","Domain":"wx2.qq.com","Expires":"2032-11-14T01:59:05Z","RawExpires":"Sun, 14-Nov-2032 01:59:05 GMT","MaxAge":0,"Secure":true,"HttpOnly":false,"SameSite":0,"Raw":"webwxuvid=b2ff8fe2430e13c57b78ee4cf4bc2aaaca7398f8aac7c3fae61d872bf1f5b1793bb86d87f6363d773112907853f5a06f; Domain=wx2.qq.com; Path=/; Expires=Sun, 14-Nov-2032 01:59:05 GMT; Secure","Unparsed":null},{"Name":"webwx_auth_ticket","Value":"CIsBENf3+tYKGoABRV0pH279Qu4VJVarM0ZjFMs0KtHgGG6wHxbv9QktsmPRgDH6jYTRr6p235H0B71M386IU1MQKAKkOCHdsgb9H8cvQymVFGdGPDt9/n6kF7OKhfEJ9vnP0Wdf5PsEAvuWNIeElBoz5XqCwcER9OJ7nzZggbGvfRhVzeuVhU3fZH0=","Path":"/","Domain":"wx2.qq.com","Expires":"2032-11-14T01:59:05Z","RawExpires":"Sun, 14-Nov-2032 01:59:05 GMT","MaxAge":0,"Secure":true,"HttpOnly":false,"SameSite":0,"Raw":"webwx_auth_ticket=CIsBENf3+tYKGoABRV0pH279Qu4VJVarM0ZjFMs0KtHgGG6wHxbv9QktsmPRgDH6jYTRr6p235H0B71M386IU1MQKAKkOCHdsgb9H8cvQymVFGdGPDt9/n6kF7OKhfEJ9vnP0Wdf5PsEAvuWNIeElBoz5XqCwcER9OJ7nzZggbGvfRhVzeuVhU3fZH0=; Domain=wx2.qq.com; Path=/; Expires=Sun, 14-Nov-2032 01:59:05 GMT; Secure","Unparsed":null}]},"BaseRequest":{"Uin":164265249,"Sid":"lhh0FVX8Vjwir/2A","Skey":"@crypt_a32bb296_60f3ac8cdcd01e425930f47088c0e2d9","DeviceID":"e486361761247535"},"LoginInfo":{"Ret":0,"WxUin":164265249,"IsGrayScale":1,"Message":"","SKey":"@crypt_a32bb296_60f3ac8cdcd01e425930f47088c0e2d9","WxSid":"lhh0FVX8Vjwir/2A","PassTicket":"%2BeGf%2BC5PKV872tdMLPB3kr7Xp%2Bgm69BgsezoWynMy54%3D"},"WechatDomain":"wx2.qq.com","UUID":"IZqDBCnF5w=="}