We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
@xxx
Mirai版本:v0.0.0-20230315231550-b461f356a30a 运行环境:win64 使用协议:AndroidPad 重现步骤:使用message.NewReply(groupMessage)方法回复一个群里的回复消息 代码:
message.NewReply(groupMessage)
sendingMessage := message.NewSendingMessage() reply := message.NewReply(groupMessage) // 从事件中获取而来 msgStr := message.NewText("测试") sendingMessage.Elements = append(sendingMessage.Elements, msgStr, reply) bot.SendGroupMessage(groupCode, sendingMessage) // bot为机器人client对象
结果:
其他说明: 原因是群聊的回复消息是At+Text+Reply组成的,是否在框架的NewReply中将其处理掉比较好?
At
Text
Reply
NewReply
以下是我目前用的解决该问题的代码:
func removeReplyAt(messages []message.IMessageElement) []message.IMessageElement { for index, msg := range messages { if msg.Type() == message.Reply { if index < 2 { // 由qq群聊发送的reply消息,reply是第三个元素。 return messages } if messages[index-1].Type() == message.Text && messages[index-2].Type() == message.At { // 当reply的前两个元素分别人At和内容为" "的text元素时,进行移除 textMsg := messages[index-1].(*message.TextElement) if textMsg.Content == " " { if index == 2 { return append(messages[2:]) } return append(messages[:index-3], messages[index:]...) } } } } return messages }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Mirai版本:v0.0.0-20230315231550-b461f356a30a
运行环境:win64
使用协议:AndroidPad
重现步骤:使用
message.NewReply(groupMessage)
方法回复一个群里的回复消息代码:
结果:
其他说明:
原因是群聊的回复消息是
At
+Text
+Reply
组成的,是否在框架的NewReply
中将其处理掉比较好?以下是我目前用的解决该问题的代码:
The text was updated successfully, but these errors were encountered: