@@ -594,6 +594,52 @@ func (p *PuppetService) MessageFile(id string) (*filebox.FileBox, error) {
594594 return NewFileBoxFromMessageFileStream (response )
595595}
596596
597+ // MessageLocation get location payload
598+ func (p * PuppetService ) MessageLocation (messageID string ) (* schemas.LocationPayload , error ) {
599+ log .Tracef ("PuppetService MessageLocation(%s)\n " , messageID )
600+
601+ response , err := p .grpcClient .MessageLocation (context .Background (), & pbwechatypuppet.MessageLocationRequest {
602+ Id : messageID ,
603+ })
604+ if err != nil {
605+ return nil , err
606+ }
607+ if response .Location == nil {
608+ return & schemas.LocationPayload {
609+ Address : "NOADDRESS" ,
610+ Name : "NONAME" ,
611+ }, nil
612+ }
613+ return & schemas.LocationPayload {
614+ Accuracy : response .Location .Accuracy ,
615+ Address : response .Location .Address ,
616+ Latitude : response .Location .Latitude ,
617+ Longitude : response .Location .Longitude ,
618+ Name : response .Location .Name ,
619+ }, nil
620+ }
621+
622+ // MessageSendLocation send location
623+ func (p * PuppetService ) MessageSendLocation (conversationID string , payload * schemas.LocationPayload ) (string , error ) {
624+ log .Tracef ("PuppetService MessageSendLocation(%s, %+v)\n " , conversationID , payload )
625+
626+ response , err := p .grpcClient .MessageSendLocation (context .Background (), & pbwechatypuppet.MessageSendLocationRequest {
627+ ConversationId : conversationID ,
628+ Location : & pbwechatypuppet.LocationPayload {
629+ Accuracy : payload .Accuracy ,
630+ Address : payload .Address ,
631+ Latitude : payload .Latitude ,
632+ Longitude : payload .Longitude ,
633+ Name : payload .Name ,
634+ },
635+ })
636+ if err != nil {
637+ return "" , err
638+ }
639+
640+ return response .Id , nil
641+ }
642+
597643// MessageRawPayload ...
598644func (p * PuppetService ) MessageRawPayload (id string ) (* schemas.MessagePayload , error ) {
599645 log .Tracef ("PuppetService MessagePayload(%s)\n " , id )
0 commit comments