From 95a4a4d188fc509fff239fe6a12826cad92c143f Mon Sep 17 00:00:00 2001 From: eatMoreApple <15055461510@163.com> Date: Tue, 3 Aug 2021 11:28:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DReply=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=9A=84SentMessage=E6=92=A4=E5=9B=9E=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=BC=95=E5=8F=91=E7=9A=84=E7=A9=BA=E6=8C=87=E9=92=88=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- message.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/message.go b/message.go index 91d64d0..1e7eac3 100644 --- a/message.go +++ b/message.go @@ -126,7 +126,12 @@ func (m *Message) Reply(msgType MessageType, content, mediaId string) (*SentMess msg := NewSendMessage(msgType, content, m.Bot.self.User.UserName, m.FromUserName, mediaId) info := m.Bot.Storage.LoginInfo request := m.Bot.Storage.Request - return m.Bot.Caller.WebWxSendMsg(msg, info, request) + sentMessage, err := m.Bot.Caller.WebWxSendMsg(msg, info, request) + if err != nil { + return nil, err + } + sentMessage.Self = m.Bot.self + return sentMessage, nil } // ReplyText 回复文本消息 @@ -491,6 +496,16 @@ func (s *SentMessage) Revoke() error { return s.Self.RevokeMessage(s) } +// CanRevoke 是否可以撤回该消息 +func (s *SentMessage) CanRevoke() bool { + i, err := strconv.ParseInt(s.ClientMsgId, 10, 64) + if err != nil { + return false + } + start := time.Unix(i/10000000, 0) + return time.Now().Sub(start) < time.Minute*2 +} + // ForwardToFriends 转发该消息给好友 func (s *SentMessage) ForwardToFriends(friends ...*Friend) error { return s.Self.ForwardMessageToFriends(s, friends...)