diff --git a/src/wechaty/accessory.py b/src/wechaty/accessory.py new file mode 100644 index 00000000..e035ed27 --- /dev/null +++ b/src/wechaty/accessory.py @@ -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 diff --git a/src/wechaty/config.py b/src/wechaty/config.py new file mode 100644 index 00000000..0a8c7ade --- /dev/null +++ b/src/wechaty/config.py @@ -0,0 +1,7 @@ +import logging + + +class FileBox: + pass + +log = logging.getLogger(__name__) \ No newline at end of file diff --git a/src/wechaty/images.py b/src/wechaty/images.py new file mode 100644 index 00000000..5016bc92 --- /dev/null +++ b/src/wechaty/images.py @@ -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 + + +