Skip to content
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

add wechaty/user/images.go #2

Merged
merged 2 commits into from
Mar 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}