Skip to content

Commit

Permalink
Merge pull request #2 from dingdayu/master
Browse files Browse the repository at this point in the history
add wechaty/user/images.go
  • Loading branch information
huan authored Mar 15, 2020
2 parents e4f3ff9 + f360e73 commit a20758e
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 0 deletions.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/wechaty/go-wechaty

go 1.14
19 changes: 19 additions & 0 deletions src/wechaty-puppet/file_box.go
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
}
9 changes: 9 additions & 0 deletions src/wechaty-puppet/puppet.go
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
}
10 changes: 10 additions & 0 deletions src/wechaty-puppet/schemas/image.go
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
)
9 changes: 9 additions & 0 deletions src/wechaty/accessory.go
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 接口
}
35 changes: 35 additions & 0 deletions src/wechaty/user/image.go
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)
}

0 comments on commit a20758e

Please sign in to comment.