Skip to content

quick test #3

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

Closed
wants to merge 4 commits into from
Closed
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
31 changes: 31 additions & 0 deletions src/wechaty/accessory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from abc import ABCMeta,abstractclassmethod
from typing import Any
from enum import Enum

class Puppet(object):

def message_image(self,id:int,image_type : Enum):
"""
docstring
:param id:
:param image_type:
:return:
"""
pass

class Accessory(object):
"""

"""
__metaclass__ = ABCMeta

def __init__(self):
self.puppet = Puppet()

@abstractclassmethod
def __str__(self):
"""
docstring
:return:
"""
raise NotImplementedError
7 changes: 7 additions & 0 deletions src/wechaty/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import logging


class FileBox:
pass

log = logging.getLogger(__name__)
67 changes: 67 additions & 0 deletions src/wechaty/images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from src.wechaty.accessory import Accessory
from src.wechaty.config import FileBox,log
from typing import Optional,Type,TypeVar
import asyncio
from enum import IntEnum

class ImageType(IntEnum):
"""
docstring ...
"""
Thumbnail = 0,
HD = 1,
Artwork = 2

class Image(Accessory):
"""
docstring ...
"""
def __init__(self,id:str) -> None:
super(Image,self).__init__()
self.id = id
log.info(f"create image : {self.__name__}")

if self.puppet is None:
raise NotImplementedError("Image class can not be instanciated without a puppet!")


@staticmethod
def create(cls:Image,id:str) -> Image:
"""
docstring
:param cls:
:param id:
:return:
"""
log.info(f"create static image : {id}")
return cls(id)

async def thumbnail(self) -> FileBox:
"""
docstring
:return:
"""
log.info(f"image thumbnail for {self.id}")
file_box = await self.puppet.message_image(self.id, ImageType.Thumbnail)
return file_box

async def hd(self) -> FileBox:
"""
docstring
:return:
"""
log.info(f"image hd for {self.id}")
file_box = await self.puppet.message_image(self.id,ImageType.HD)
return file_box

async def artwork(self) -> FileBox:
"""
docstring
:return:
"""
log.info(f"image artwork for {self.id}")
file_box = await self.puppet.message_image(self.id, ImageType.Artwork)
return file_box