From 21846a68c36573c9c3033bfd34b01f8aa9bc39d2 Mon Sep 17 00:00:00 2001 From: Chenwe_i_lin <1846913566@qq.com> Date: Sun, 1 Mar 2020 11:42:59 +0800 Subject: [PATCH] support: for image component attr url --- mirai/message/components.py | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/mirai/message/components.py b/mirai/message/components.py index 07ed1df..19f8fbb 100644 --- a/mirai/message/components.py +++ b/mirai/message/components.py @@ -4,7 +4,7 @@ from mirai.misc import findKey, printer, ImageRegex, getMatchedString, randomRangedNumberString as rd from mirai.face import QQFaces from mirai.message.base import BaseMessageComponent, MessageComponentTypes -from pydantic import Field, validator +from pydantic import Field, validator, HttpUrl from pydantic.generics import GenericModel from mirai.network import fetch, session from mirai.misc import ImageType @@ -62,6 +62,7 @@ def toString(self): class Image(BaseMessageComponent): type: MessageComponentTypes = "Image" imageId: UUID + url: HttpUrl @validator("imageId", always=True, pre=True) @classmethod @@ -80,10 +81,6 @@ def imageId_formater(cls, v): def toString(self): return f"[Image::{self.imageId}]" - @property - def url(self): - return f"http://gchat.qpic.cn/gchatpic_new/{rd()}/{rd()}-{rd()}-{self.imageId.hex.upper()}/0" - def asGroupImage(self) -> str: return f"{{{str(self.imageId).upper()}}}.jpg" @@ -126,11 +123,4 @@ class ComponentTypes(Enum): "Image": Image, "Source": Source, "Unknown": Unknown -} - -from ..context import message, event -from mirai.prototypes.context import ( - MessageContextBody, - EventContextBody -) -from mirai.protocol import MiraiProtocol \ No newline at end of file +} \ No newline at end of file