-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from dingdayu/master
add wechaty/user/images.go
- Loading branch information
Showing
6 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/wechaty/go-wechaty | ||
|
||
go 1.14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package wechaty_puppet | ||
|
||
type FileBox struct { | ||
} | ||
|
||
// ToJson todo:: no finish | ||
func (f *FileBox) ToJson() map[string]interface{} { | ||
return nil | ||
} | ||
|
||
// ToFile todo:: no finish | ||
func (f *FileBox) ToFile(path string) { | ||
return | ||
} | ||
|
||
// ToFile todo:: no finish | ||
func (f *FileBox) FromQrCode(path string) { | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package wechaty_puppet | ||
|
||
import ( | ||
"github.com/wechaty/go-wechaty/src/wechaty-puppet/schemas" | ||
) | ||
|
||
type Puppet interface { | ||
MessageImage(messageId string, imageType schemas.ImageType) FileBox | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package schemas | ||
|
||
type ImageType uint8 | ||
|
||
const ( | ||
Unknown ImageType = 0 | ||
Thumbnail = 1 | ||
HD = 2 | ||
Artwork = 3 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package wechaty | ||
|
||
import ( | ||
wechatyPuppet "github.com/wechaty/go-wechaty/src/wechaty-puppet" | ||
) | ||
|
||
type Accessory struct { | ||
Puppet wechatyPuppet.Puppet // wechat-puppet 的 Puppet 接口 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package user | ||
|
||
import ( | ||
"github.com/wechaty/go-wechaty/src/wechaty" | ||
wechatyPuppet "github.com/wechaty/go-wechaty/src/wechaty-puppet" | ||
"github.com/wechaty/go-wechaty/src/wechaty-puppet/schemas" | ||
) | ||
|
||
type Images struct { | ||
wechaty.Accessory | ||
ImageId string | ||
} | ||
|
||
// NewImages create image struct | ||
func NewImages(id string, accessory wechaty.Accessory) *Images { | ||
if accessory.Puppet == nil { | ||
panic("Image class can not be instanciated without a puppet!") | ||
} | ||
return &Images{accessory, id} | ||
} | ||
|
||
// Thumbnail message thumbnail images | ||
func (img *Images) Thumbnail() wechatyPuppet.FileBox { | ||
return img.Accessory.Puppet.MessageImage(img.ImageId, schemas.Thumbnail) | ||
} | ||
|
||
// HD message hd images | ||
func (img *Images) HD() wechatyPuppet.FileBox { | ||
return img.Accessory.Puppet.MessageImage(img.ImageId, schemas.HD) | ||
} | ||
|
||
// Artwork message artwork images | ||
func (img *Images) Artwork() wechatyPuppet.FileBox { | ||
return img.Accessory.Puppet.MessageImage(img.ImageId, schemas.Artwork) | ||
} |