-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathresource.py
87 lines (73 loc) · 2.01 KB
/
resource.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from __future__ import annotations
from pathlib import Path
from avilla.core.context import Context
from avilla.core.resource import Resource
from avilla.core.selector import Selector
class RedResource(Resource[bytes]):
id: str
ctx: Context
size: int
name: str
elem: str
uuid: str
def __init__(self, ctx: Context, selector: Selector, id: str, size: int, name: str, elem: str, uuid: str):
super().__init__(selector)
self.ctx = ctx
self.id = id
self.size = size
self.name = name
self.elem = elem
self.uuid = uuid
class RedFileResource(RedResource):
pass
class RedImageResource(RedResource):
def __init__(
self,
ctx: Context,
selector: Selector,
id: str,
size: int,
name: str,
elem: str,
uuid: str,
path: str | Path,
width: int,
height: int,
):
super().__init__(ctx, selector, id, size, name, elem, uuid)
self.path = Path(path)
self.width = width
self.height = height
@property
def url(self) -> str:
if self.ctx.scene.last_key == "friend":
return f"https://c2cpicdw.qpic.cn/offpic_new//{self.ctx.scene.last_value}-0-{self.id.upper()}/0"
return f"https://gchat.qpic.cn/gchatpic_new/0/0-0-{self.id.upper()}/0"
class RedVoiceResource(RedResource):
def __init__(
self,
ctx: Context,
selector: Selector,
id: str,
size: int,
name: str,
elem: str,
uuid: str,
path: str | Path,
):
super().__init__(ctx, selector, id, size, name, elem, uuid)
self.path = Path(path)
class RedVideoResource(RedResource):
def __init__(
self,
ctx: Context,
selector: Selector,
id: str,
size: int,
name: str,
elem: str,
uuid: str,
path: str | Path,
):
super().__init__(ctx, selector, id, size, name, elem, uuid)
self.path = Path(path)