satori-python 1.3.4__py3-none-any.whl → 1.3.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
satori/__init__.py CHANGED
@@ -45,7 +45,7 @@ from .model import Role as Role
45
45
  from .model import Upload as Upload
46
46
  from .model import User as User
47
47
 
48
- __version__ = "1.3.4"
48
+ __version__ = "1.3.6"
49
49
 
50
50
 
51
51
  MessageReceipt = MessageObject
satori/element.py CHANGED
@@ -124,10 +124,12 @@ class Element:
124
124
  return self.dumps()
125
125
 
126
126
  def __repr__(self) -> str:
127
+ if not self._attrs:
128
+ self._attrs = {k: v for k, v in self.__dict__.items() if not k.startswith("_")}
127
129
  args = {**self._attrs}
128
130
  elem = f"{self.__class__.__name__}(" + ", ".join(f"{k}={v!r}" for k, v in args.items())
129
131
  if self._children:
130
- elem += ", { " + ", ".join(repr(i) for i in self._children) + " }"
132
+ elem += ", [" + ", ".join(repr(i) for i in self._children) + "]"
131
133
  return elem + ")"
132
134
 
133
135
  def __call__(self, *content: "str | Element"):
@@ -255,7 +257,6 @@ class Link(Element):
255
257
  class Resource(Element):
256
258
  src: str
257
259
  title: str | None = None
258
- extra: InitVar[dict[str, Any] | None] = None
259
260
  cache: bool | None = None
260
261
  timeout: int | None = None
261
262
 
@@ -269,14 +270,15 @@ class Resource(Element):
269
270
  raw: bytes | BytesIO | None = None,
270
271
  mime: str | None = None,
271
272
  name: str | None = None,
273
+ width: int | None = None,
274
+ height: int | None = None,
272
275
  duration: float | None = None,
273
276
  poster: str | None = None,
274
- extra: dict[str, Any] | None = None,
275
277
  cache: bool | None = None,
276
278
  timeout: int | None = None,
277
279
  **kwargs,
278
280
  ) -> Self:
279
- data: dict[str, Any] = {"extra": extra, **kwargs}
281
+ data: dict[str, Any] = {**kwargs}
280
282
  if url is not None:
281
283
  data |= {"src": url}
282
284
  elif path:
@@ -294,6 +296,10 @@ class Resource(Element):
294
296
  raise ValueError(f"{cls} need at least one of url, path and raw")
295
297
  if name is not None:
296
298
  data["title"] = name
299
+ if width is not None and cls in (Image, Video):
300
+ data["width"] = width
301
+ if height is not None and cls in (Image, Video):
302
+ data["height"] = height
297
303
  if duration is not None and cls is Audio:
298
304
  data["duration"] = duration
299
305
  if poster is not None and cls in (Video, Audio, File):
@@ -302,11 +308,7 @@ class Resource(Element):
302
308
  data["cache"] = cache
303
309
  if timeout is not None:
304
310
  data["timeout"] = timeout
305
- return cls(**data)
306
-
307
- def __post_init__(self, extra: dict[str, Any] | None = None):
308
- if extra:
309
- self._attrs.update(extra)
311
+ return cls.unpack(data)
310
312
 
311
313
 
312
314
  @dataclass(repr=False)
@@ -487,7 +489,7 @@ class Message(Element):
487
489
  self,
488
490
  id: str | None = None,
489
491
  forward: bool | None = None,
490
- content: list[str | Element] | None = None,
492
+ content: Sequence[str | Element] | None = None,
491
493
  ):
492
494
  self.id = id
493
495
  self.forward = forward
@@ -580,7 +582,7 @@ class Custom(Element):
580
582
  attrs: dict[str, Any] | None = None,
581
583
  children: Sequence[str | Element] | None = None,
582
584
  ):
583
- self.type = type
585
+ self._type = type
584
586
  if not hasattr(self, "_attrs"):
585
587
  self._attrs = attrs or {}
586
588
  else:
@@ -593,7 +595,21 @@ class Custom(Element):
593
595
  @property
594
596
  @override
595
597
  def tag(self) -> str:
596
- return self.type
598
+ return self._type
599
+
600
+ def __repr__(self) -> str:
601
+ if not self._attrs:
602
+ self._attrs = {k: v for k, v in self.__dict__.items() if not k.startswith("_")}
603
+ args = {**self._attrs}
604
+ elem = (
605
+ f"{self.__class__.__name__}({self._type!r}"
606
+ + ", {"
607
+ + ", ".join(f"{k!r}: {v!r}" for k, v in args.items())
608
+ + "}"
609
+ )
610
+ if self._children:
611
+ elem += ", [" + ", ".join(repr(i) for i in self._children) + "]"
612
+ return elem + ")"
597
613
 
598
614
 
599
615
  @dataclass(repr=False)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: satori-python
3
- Version: 1.3.4
3
+ Version: 1.3.6
4
4
  Summary: Satori Protocol SDK for python
5
5
  Home-page: https://github.com/RF-Tar-Railt/satori-python
6
6
  Author-Email: RF-Tar-Railt <rf_tar_railt@qq.com>
@@ -1,4 +1,4 @@
1
- satori/__init__.py,sha256=FQefy9qVHoveZvovXuXDhPFX775QW0B8IutY41otMe8,1888
1
+ satori/__init__.py,sha256=iqFO7AcoOIYcQ6H2Hcd2CHDqgunj4qSpj5_awItfaCE,1888
2
2
  satori/_vendor/fleep.py,sha256=_zKP7iY3mMQr0rC5KbgkbkMorT3KVLeIsWPLIUa0Y34,16347
3
3
  satori/client/__init__.py,sha256=1HLiYmYZoScymOzTuOVZht99eREXMUT09F8PZzvAMPA,14484
4
4
  satori/client/account.py,sha256=HP7BJWkN69SB9ldNIjHxWlXcrmB-IPnTnYqm3lBMvl8,2742
@@ -11,7 +11,7 @@ satori/client/network/webhook.py,sha256=N1zcJGx-Ijwtc0dIsPWzdnJSLi0ydQTengHBxtbb
11
11
  satori/client/network/websocket.py,sha256=oZtiFLywP_Rw-_I-hl32nShCTTQ1XKlv0BhWJj53x9Y,8476
12
12
  satori/client/protocol.py,sha256=hXrtgh-ypiF1W-dTl5I4LBWg8P2VTNKYQWFq8aRCeeo,28577
13
13
  satori/const.py,sha256=6TQAIlgNq7fHLiadxGUU-mzkffOcpRrEvq5yrWYMuGc,2738
14
- satori/element.py,sha256=Ya0iDwMpgmfdluHWEYEhbaC9fdRZuYRJfjMwLM4vb_E,20707
14
+ satori/element.py,sha256=7a1azqihsYBNe7BHGvN-MQH4jOsTj47Ei9h5qwDVu9M,21355
15
15
  satori/event.py,sha256=yC6rKaa7JbeOZ4Un1rX-Isvm3EcR7e782nxYf1j6JdM,1060
16
16
  satori/exception.py,sha256=edKeuLRZAQxyCdw1_XCgOtv5tIHkfHw0Die9B818_HM,545
17
17
  satori/model.py,sha256=L8Wlk4zGlnR5kM4rAsaXvPufxdwmUsshkFY9PLGj8tY,17614
@@ -25,7 +25,7 @@ satori/server/model.py,sha256=zzjNa3iBFkd8crZIVTrEisPaB0g8JsxV4fA2rRU0maw,1105
25
25
  satori/server/route.py,sha256=kpelAX0kYQbJncp5biWi8pWRcEIez9m9sJN8NF3sjn4,10654
26
26
  satori/server/utils.py,sha256=hMNqLzbzcwyLJO-sGncO5kuviiW5Y6k34fj4AS2iVWQ,910
27
27
  satori/utils.py,sha256=N8HEw-DOXxOBwFHmmXgqPdMh6AXjiGR0ZGa1zBPH6EI,822
28
- satori_python-1.3.4.dist-info/METADATA,sha256=06M-7vqckbF3Ib-6quslfGmB05p_7gg_mQ_N0IkBy-M,5511
29
- satori_python-1.3.4.dist-info/WHEEL,sha256=rSwsxJWe3vzyR5HCwjWXQruDgschpei4h_giTm0dJVE,90
30
- satori_python-1.3.4.dist-info/licenses/LICENSE,sha256=2EDswKd1M1648judap8BEEwp3Jz6IpfFP2wYVdU0Y2o,1069
31
- satori_python-1.3.4.dist-info/RECORD,,
28
+ satori_python-1.3.6.dist-info/METADATA,sha256=ykbOROhEgZKgXqojHaiSPc4UOB8Rr13qBY7zXLBwCyg,5511
29
+ satori_python-1.3.6.dist-info/WHEEL,sha256=rSwsxJWe3vzyR5HCwjWXQruDgschpei4h_giTm0dJVE,90
30
+ satori_python-1.3.6.dist-info/licenses/LICENSE,sha256=2EDswKd1M1648judap8BEEwp3Jz6IpfFP2wYVdU0Y2o,1069
31
+ satori_python-1.3.6.dist-info/RECORD,,