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() ``` ##### 语音消息