From 24dc14c1b166f7aaacc44c6029ed0128fb111d13 Mon Sep 17 00:00:00 2001 From: dingdayu <614422099@qq.com> Date: Sun, 15 Mar 2020 21:25:13 +0800 Subject: [PATCH 1/2] add wechaty/user/images.go Signed-off-by: dingdayu <614422099@qq.com> --- go.mod | 3 +++ wechaty-puppet/file_box.go | 19 ++++++++++++++++++ wechaty-puppet/puppet.go | 9 +++++++++ wechaty-puppet/schemas/image.go | 10 ++++++++++ wechaty/accessory.go | 9 +++++++++ wechaty/user/image.go | 35 +++++++++++++++++++++++++++++++++ 6 files changed, 85 insertions(+) create mode 100644 go.mod create mode 100644 wechaty-puppet/file_box.go create mode 100644 wechaty-puppet/puppet.go create mode 100644 wechaty-puppet/schemas/image.go create mode 100644 wechaty/accessory.go create mode 100644 wechaty/user/image.go 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/wechaty-puppet/file_box.go b/wechaty-puppet/file_box.go new file mode 100644 index 0000000..3bd3bbc --- /dev/null +++ b/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/wechaty-puppet/puppet.go b/wechaty-puppet/puppet.go new file mode 100644 index 0000000..5527e3f --- /dev/null +++ b/wechaty-puppet/puppet.go @@ -0,0 +1,9 @@ +package wechaty_puppet + +import ( + "github.com/wechaty/go-wechaty/wechaty-puppet/schemas" +) + +type Puppet interface { + MessageImage(messageId string, imageType schemas.ImageType) FileBox +} diff --git a/wechaty-puppet/schemas/image.go b/wechaty-puppet/schemas/image.go new file mode 100644 index 0000000..827debf --- /dev/null +++ b/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/wechaty/accessory.go b/wechaty/accessory.go new file mode 100644 index 0000000..e2dfdb8 --- /dev/null +++ b/wechaty/accessory.go @@ -0,0 +1,9 @@ +package wechaty + +import ( + wechatyPuppet "github.com/wechaty/go-wechaty/wechaty-puppet" +) + +type Accessory struct { + Puppet wechatyPuppet.Puppet // wechat-puppet 的 Puppet 接口 +} diff --git a/wechaty/user/image.go b/wechaty/user/image.go new file mode 100644 index 0000000..7f331a1 --- /dev/null +++ b/wechaty/user/image.go @@ -0,0 +1,35 @@ +package user + +import ( + "github.com/wechaty/go-wechaty/wechaty" + wechatyPuppet "github.com/wechaty/go-wechaty/wechaty-puppet" + "github.com/wechaty/go-wechaty/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) +} From f360e734900047ed847014621a4d48eb0a75a4b5 Mon Sep 17 00:00:00 2001 From: dingdayu <614422099@qq.com> Date: Sun, 15 Mar 2020 21:55:20 +0800 Subject: [PATCH 2/2] move wechaty & wechaty-puppet to /src Signed-off-by: dingdayu <614422099@qq.com> --- {wechaty-puppet => src/wechaty-puppet}/file_box.go | 0 {wechaty-puppet => src/wechaty-puppet}/puppet.go | 2 +- {wechaty-puppet => src/wechaty-puppet}/schemas/image.go | 0 {wechaty => src/wechaty}/accessory.go | 2 +- {wechaty => src/wechaty}/user/image.go | 6 +++--- 5 files changed, 5 insertions(+), 5 deletions(-) rename {wechaty-puppet => src/wechaty-puppet}/file_box.go (100%) rename {wechaty-puppet => src/wechaty-puppet}/puppet.go (68%) rename {wechaty-puppet => src/wechaty-puppet}/schemas/image.go (100%) rename {wechaty => src/wechaty}/accessory.go (64%) rename {wechaty => src/wechaty}/user/image.go (82%) diff --git a/wechaty-puppet/file_box.go b/src/wechaty-puppet/file_box.go similarity index 100% rename from wechaty-puppet/file_box.go rename to src/wechaty-puppet/file_box.go diff --git a/wechaty-puppet/puppet.go b/src/wechaty-puppet/puppet.go similarity index 68% rename from wechaty-puppet/puppet.go rename to src/wechaty-puppet/puppet.go index 5527e3f..289d0f9 100644 --- a/wechaty-puppet/puppet.go +++ b/src/wechaty-puppet/puppet.go @@ -1,7 +1,7 @@ package wechaty_puppet import ( - "github.com/wechaty/go-wechaty/wechaty-puppet/schemas" + "github.com/wechaty/go-wechaty/src/wechaty-puppet/schemas" ) type Puppet interface { diff --git a/wechaty-puppet/schemas/image.go b/src/wechaty-puppet/schemas/image.go similarity index 100% rename from wechaty-puppet/schemas/image.go rename to src/wechaty-puppet/schemas/image.go diff --git a/wechaty/accessory.go b/src/wechaty/accessory.go similarity index 64% rename from wechaty/accessory.go rename to src/wechaty/accessory.go index e2dfdb8..c6c7027 100644 --- a/wechaty/accessory.go +++ b/src/wechaty/accessory.go @@ -1,7 +1,7 @@ package wechaty import ( - wechatyPuppet "github.com/wechaty/go-wechaty/wechaty-puppet" + wechatyPuppet "github.com/wechaty/go-wechaty/src/wechaty-puppet" ) type Accessory struct { diff --git a/wechaty/user/image.go b/src/wechaty/user/image.go similarity index 82% rename from wechaty/user/image.go rename to src/wechaty/user/image.go index 7f331a1..09974f8 100644 --- a/wechaty/user/image.go +++ b/src/wechaty/user/image.go @@ -1,9 +1,9 @@ package user import ( - "github.com/wechaty/go-wechaty/wechaty" - wechatyPuppet "github.com/wechaty/go-wechaty/wechaty-puppet" - "github.com/wechaty/go-wechaty/wechaty-puppet/schemas" + "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 {