-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
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
feat(location): support location msg #162
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,16 @@ type PuppetMock struct { | |
*wechatyPuppet.Puppet | ||
} | ||
|
||
func (p *PuppetMock) MessageLocation(messageID string) (*schemas.LocationPayload, error) { | ||
//TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
func (p *PuppetMock) MessageSendLocation(conversationID string, payload *schemas.LocationPayload) (string, error) { | ||
//TODO implement me | ||
panic("implement me") | ||
} | ||
Comment on lines
+20
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to Would you like assistance in suggesting a basic implementation or further documentation for this method? |
||
|
||
func NewPuppetMock(option wechatyPuppet.Option) (*PuppetMock, error) { | ||
puppetAbstract, err := wechatyPuppet.NewPuppet(option) | ||
if err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package schemas | ||
|
||
type LocationPayload struct { | ||
Accuracy float32 `json:"accuracy"` // Estimated horizontal accuracy of this location, radial, in meters. (same as Android & iOS API) | ||
Address string `json:"address"` // 北京市北京市海淀区45 Chengfu Rd | ||
Latitude float64 `json:"latitude"` // 39.995120999999997 | ||
Longitude float64 `json:"longitude"` // 116.3341 | ||
Name string `json:"name"` // 东升乡人民政府(海淀区成府路45号) | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3,13 +3,13 @@ package schemas | |||||||||||||||||
import "encoding/json" | ||||||||||||||||||
|
||||||||||||||||||
type UrlLinkPayload struct { | ||||||||||||||||||
Description string `json:"description"` | ||||||||||||||||||
ThumbnailUrl string `json:"thumbnailUrl"` | ||||||||||||||||||
Title string `json:"title"` | ||||||||||||||||||
Url string `json:"url"` | ||||||||||||||||||
Description string `json:"description"` | ||||||||||||||||||
ThumbnailUrl string `json:"thumbnailUrl"` | ||||||||||||||||||
Title string `json:"title"` | ||||||||||||||||||
Url string `json:"url"` | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
func (u *UrlLinkPayload) ToJson() string { | ||||||||||||||||||
b, _ := json.Marshal(u) | ||||||||||||||||||
return string(b) | ||||||||||||||||||
b, _ := json.Marshal(u) | ||||||||||||||||||
return string(b) | ||||||||||||||||||
Comment on lines
+13
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider handling the error returned by func (u *UrlLinkPayload) ToJson() string {
- b, _ := json.Marshal(u)
+ b, err := json.Marshal(u)
+ if err != nil {
+ // Handle error (e.g., log it, return an error message, etc.)
+ return ""
+ }
return string(b)
} Committable suggestion
Suggested change
|
||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,44 @@ | ||||||||||||||
package user | ||||||||||||||
|
||||||||||||||
import ( | ||||||||||||||
"fmt" | ||||||||||||||
"github.com/wechaty/go-wechaty/wechaty-puppet/schemas" | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
type Location struct { | ||||||||||||||
payload *schemas.LocationPayload | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
func NewLocation(payload *schemas.LocationPayload) *Location { | ||||||||||||||
return &Location{ | ||||||||||||||
payload: payload, | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
func (l *Location) Payload() schemas.LocationPayload { | ||||||||||||||
return *l.payload | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
func (l *Location) String() string { | ||||||||||||||
return fmt.Sprintf("Location<%s>", l.payload.Name) | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
func (l *Location) Address() string { | ||||||||||||||
return l.payload.Address | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
func (l *Location) Latitude() float64 { | ||||||||||||||
return l.payload.Latitude | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
func (l *Location) longitude() float64 { | ||||||||||||||
return l.payload.Longitude | ||||||||||||||
} | ||||||||||||||
Comment on lines
+34
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method - func (l *Location) longitude() float64 {
+ func (l *Location) Longitude() float64 { Committable suggestion
Suggested change
|
||||||||||||||
|
||||||||||||||
func (l *Location) Name() string { | ||||||||||||||
return l.payload.Name | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
func (l *Location) Accuracy() float32 { | ||||||||||||||
return l.payload.Accuracy | ||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
MessageLocation
method is currently a placeholder. Consider documenting the expected behavior or purpose of this method for future implementation.Would you like me to suggest a basic implementation or further documentation for this method?