diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..5f98e12 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/wechaty/go-wechaty + +go 1.14 diff --git a/src/wechaty-puppet/file_box.go b/src/wechaty-puppet/file_box.go new file mode 100644 index 0000000..3bd3bbc --- /dev/null +++ b/src/wechaty-puppet/file_box.go @@ -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 +} diff --git a/src/wechaty-puppet/puppet.go b/src/wechaty-puppet/puppet.go new file mode 100644 index 0000000..289d0f9 --- /dev/null +++ b/src/wechaty-puppet/puppet.go @@ -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 +} diff --git a/src/wechaty-puppet/schemas/image.go b/src/wechaty-puppet/schemas/image.go new file mode 100644 index 0000000..827debf --- /dev/null +++ b/src/wechaty-puppet/schemas/image.go @@ -0,0 +1,10 @@ +package schemas + +type ImageType uint8 + +const ( + Unknown ImageType = 0 + Thumbnail = 1 + HD = 2 + Artwork = 3 +) diff --git a/src/wechaty/accessory.go b/src/wechaty/accessory.go new file mode 100644 index 0000000..c6c7027 --- /dev/null +++ b/src/wechaty/accessory.go @@ -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 接口 +} diff --git a/src/wechaty/user/image.go b/src/wechaty/user/image.go new file mode 100644 index 0000000..09974f8 --- /dev/null +++ b/src/wechaty/user/image.go @@ -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) +}