Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

func (m *Message) ReplyText(content string) (*SentMessage, error) 报错 Ret(1204) #110

Closed
YXH-YXH opened this issue Sep 25, 2022 · 10 comments
Labels
help wanted Extra attention is needed

Comments

@YXH-YXH
Copy link

YXH-YXH commented Sep 25, 2022

Bot.MessageHandler // 注册消息处理函数 类似下面这样

func m2essageHandler(msg *openwechat.Message) {
	sentMsg, err := msg.ReplyText("filehelper")
	if err != nil {
		log.Print(err)
	}else{
		log.Printf("[自动回复]: %v --> %v %v", sentMsg.SendMessage.FromUserName, sentMsg.SendMessage.ToUserName, sentMsg.SendMessage)
	}
}

log.Print(err)返回了Ret(1204)我不清楚是怎么回事

但是使用
Self.SendTextToFriend函数可以成功发送消息
msg.Bot.GetCurrentUser().SendTextToFriend(friend *Friend, text string) (*SentMessage, error)
类似下面这样

func m2essageHandler(msg *openwechat.Message) {
	self, _ = msg.Bot.GetCurrentUser()
        sentMsg2, err := self.SendTextToFriend(openwechat.NewFriendHelper(self), "pong") // 给文件助手发消息
}
@eatmoreapple
Copy link
Owner

不是所有的消息都是可以回复的,有的是系统消息
你下面的那种写法是只发送给文件传输助手

@wychootf4
Copy link

@eatmoreapple 你好,我也遇到了相同的问题,是在对我自己发送消息时出现的

@eatmoreapple eatmoreapple added the help wanted Extra attention is needed label Dec 9, 2022
@LSJCoder
Copy link

@eatmoreapple 你好,我也遇到了相同的问题,是在对我自己发送消息时出现的

我也遇到了,你解决了吗

@Joey-J3
Copy link

Joey-J3 commented Dec 14, 2022

遇到了同样的问题,复现方式:登陆 a 账号之后,再登陆 b 账号,b 账号接收消息报错 Ret(1204)

@MichealJl
Copy link

我收到群里面自己的消息,然后回复 就会报错1204,msg.IsComeFromGroup()这里返回的是true 但是获取到的nickname是我自己的昵称不是群的昵称

@riba2534
Copy link

我也遇到了,msg.ReplyText 回复自己的消息就会报错

@riba2534
Copy link

我也遇到了,msg.ReplyText 回复自己的消息就会报错

我自己改了改代码解决了。。

@JLLJHD
Copy link

JLLJHD commented Sep 22, 2023

@riba2534 怎么修改的求教

@eatmoreapple
Copy link
Owner

无法发送消息给自己,否则会返回1204的错误

@savannah1099
Copy link

在发送ReplyText之前判断一下,如果是自己发送的,给一个另外的识别码。方法均来自mssage.go(/usr/local/go/bin/pkg/mod/github.com/eatmoreapple/openwechat@v1.2.1/message.go)
if reply != nil {
msg.FromUserName = func() string {
s := msg.FromUserName
if msg.IsSendBySelf() {
s = msg.ToUserName
}
return s
}()
_, err = msg.ReplyText(*reply)
if err != nil {
log.Println(err)
}
return err
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

9 participants