修复 receiver 为 文件传输助手的时, receiver 找不到的问题

This commit is contained in:
eatmoreapple 2022-11-18 17:32:06 +08:00
parent 21eaf0c137
commit 8fc242b794
2 changed files with 6 additions and 3 deletions

View File

@ -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 {

1
test.json Normal file
View File

@ -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=="}