From 3fc3e44d78bf89d2de5c0b6c1413199f9d3d6d08 Mon Sep 17 00:00:00 2001 From: MiiW Date: Mon, 14 Nov 2022 01:15:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=9E=E6=97=B6=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E6=B6=88=E6=81=AF=E5=B9=B6=E9=87=8D=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MiiW --- message.go | 16 ++++++++++++++-- source/message.md | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/message.go b/message.go index 3ce8d7c..be2992f 100644 --- a/message.go +++ b/message.go @@ -185,8 +185,20 @@ func (m *Message) IsText() bool { return m.MsgType == MsgTypeText && m.Url == "" } -func (m *Message) IsMap() bool { - return m.MsgType == MsgTypeText && m.Url != "" +func (m *Message) IsLocation() bool { + return m.MsgType == MsgTypeText && strings.Contains(m.Url, "api.map.qq.com") && strings.Contains(m.Content, "pictype=location") +} + +func (m *Message) IsRealtimeLocation() bool { + return m.IsRealtimeLocationStart() || m.IsRealtimeLocationStop() +} + +func (m *Message) IsRealtimeLocationStart() bool { + return m.MsgType == MsgTypeApp && m.AppMsgType == AppMsgTypeRealtimeShareLocation +} + +func (m *Message) IsRealtimeLocationStop() bool { + return m.MsgType == MsgTypeSys && m.Content == "位置共享已经结束" } func (m *Message) IsPicture() bool { diff --git a/source/message.md b/source/message.md index d3d99f1..786c0c9 100644 --- a/source/message.md +++ b/source/message.md @@ -51,7 +51,7 @@ msg.IsPicture() ##### 位置消息 ```go -msg.IsMap() +msg.IsLocation() ``` ##### 语音消息