satori-python-client 0.18.1__tar.gz → 1.3.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  includes = ["src/satori/client"]
2
2
  raw-dependencies = [
3
- "satori-python-core >= 0.18.0",
3
+ "satori-python-core<1.4.0,>= 1.3.0",
4
4
  "graia-amnesia >= 0.11.0",
5
5
  ]
6
6
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: satori-python-client
3
- Version: 0.18.1
3
+ Version: 1.3.0
4
4
  Summary: Satori Protocol SDK for python, specify client part
5
5
  Home-page: https://github.com/RF-Tar-Railt/satori-python
6
6
  Author-Email: RF-Tar-Railt <rf_tar_railt@qq.com>
@@ -19,7 +19,7 @@ Project-URL: Repository, https://github.com/RF-Tar-Railt/satori-python
19
19
  Requires-Python: <4.0,>=3.10
20
20
  Requires-Dist: aiohttp>=3.9.3
21
21
  Requires-Dist: launart>=0.8.2
22
- Requires-Dist: satori-python-core>=0.18.0
22
+ Requires-Dist: satori-python-core<1.4.0,>=1.3.0
23
23
  Requires-Dist: graia-amnesia>=0.11.0
24
24
  Description-Content-Type: text/markdown
25
25
 
@@ -73,13 +73,13 @@ pip install satori-python-server
73
73
 
74
74
  ### 官方适配器
75
75
 
76
- | 适配器 | 安装 | 路径 |
77
- |------------|----------------------------------------------|--------------------------------------------------------------------|
78
- | Satori | `pip install satori-python-adapter-satori` | satori.adapters.satori |
79
- | OneBot V11 | `pip install satori-python-adapter-onebot11` | satori.adapters.onebot11.forward, satori.adapters.onebot11.reverse |
80
- | Console | `pip install satori-python-adapter-console` | satori.adapters.console |
81
- | Milky | `pip install satori-python-adapter-milky` | satori.adapters.milky.main, satori.adapters.milky.webhook |
82
- | QQ | `pip install satori-python-adapter-qq` | satori.adapters.qq.main, satori.adapters.qq.websocket |
76
+ | 适配器 | 安装 | 路径 |
77
+ |------------|----------------------------------------------|--------------------------------------------------------------------------------------|
78
+ | Satori | `pip install satori-python-adapter-satori` | satori.adapters.satori |
79
+ | OneBot V11 | `pip install satori-python-adapter-onebot11` | satori.adapters.onebot11.forward, satori.adapters.onebot11.reverse |
80
+ | Console | `pip install satori-python-adapter-console` | satori.adapters.console |
81
+ | Milky | `pip install satori-python-adapter-milky` | satori.adapters.milky.main, satori.adapters.milky.webhook, satori.adapters.milky.sse |
82
+ | QQ | `pip install satori-python-adapter-qq` | satori.adapters.qq.main, satori.adapters.qq.websocket |
83
83
 
84
84
  ### 社区适配器
85
85
 
@@ -48,13 +48,13 @@ pip install satori-python-server
48
48
 
49
49
  ### 官方适配器
50
50
 
51
- | 适配器 | 安装 | 路径 |
52
- |------------|----------------------------------------------|--------------------------------------------------------------------|
53
- | Satori | `pip install satori-python-adapter-satori` | satori.adapters.satori |
54
- | OneBot V11 | `pip install satori-python-adapter-onebot11` | satori.adapters.onebot11.forward, satori.adapters.onebot11.reverse |
55
- | Console | `pip install satori-python-adapter-console` | satori.adapters.console |
56
- | Milky | `pip install satori-python-adapter-milky` | satori.adapters.milky.main, satori.adapters.milky.webhook |
57
- | QQ | `pip install satori-python-adapter-qq` | satori.adapters.qq.main, satori.adapters.qq.websocket |
51
+ | 适配器 | 安装 | 路径 |
52
+ |------------|----------------------------------------------|--------------------------------------------------------------------------------------|
53
+ | Satori | `pip install satori-python-adapter-satori` | satori.adapters.satori |
54
+ | OneBot V11 | `pip install satori-python-adapter-onebot11` | satori.adapters.onebot11.forward, satori.adapters.onebot11.reverse |
55
+ | Console | `pip install satori-python-adapter-console` | satori.adapters.console |
56
+ | Milky | `pip install satori-python-adapter-milky` | satori.adapters.milky.main, satori.adapters.milky.webhook, satori.adapters.milky.sse |
57
+ | QQ | `pip install satori-python-adapter-qq` | satori.adapters.qq.main, satori.adapters.qq.websocket |
58
58
 
59
59
  ### 社区适配器
60
60
 
@@ -7,7 +7,7 @@ authors = [
7
7
  dependencies = [
8
8
  "aiohttp>=3.9.3",
9
9
  "launart>=0.8.2",
10
- "satori-python-core >= 0.18.0",
10
+ "satori-python-core<1.4.0,>= 1.3.0",
11
11
  "graia-amnesia >= 0.11.0",
12
12
  ]
13
13
  description = "Satori Protocol SDK for python, specify client part"
@@ -24,7 +24,7 @@ classifiers = [
24
24
  "Programming Language :: Python :: 3.12",
25
25
  "Operating System :: OS Independent",
26
26
  ]
27
- version = "0.18.1"
27
+ version = "1.3.0"
28
28
 
29
29
  [project.license]
30
30
  text = "MIT"
@@ -152,6 +152,15 @@ class App(Service):
152
152
  Callable[[Account, events.GuildRoleEvent], Awaitable[Any]],
153
153
  ]: ...
154
154
 
155
+ @overload
156
+ def register_on(
157
+ self,
158
+ event_type: Literal[EventType.GUILD_EMOJI_ADDED, EventType.GUILD_EMOJI_REMOVED, EventType.GUILD_EMOJI_UPDATED],
159
+ ) -> Callable[
160
+ [Callable[[Account, events.GuildEmojiEvent], Awaitable[Any]]],
161
+ Callable[[Account, events.GuildEmojiEvent], Awaitable[Any]],
162
+ ]: ...
163
+
155
164
  @overload
156
165
  def register_on(
157
166
  self, event_type: Literal[EventType.LOGIN_ADDED, EventType.LOGIN_REMOVED, EventType.LOGIN_UPDATED]
@@ -20,13 +20,14 @@ class ApiInfo:
20
20
  port: int = 5140
21
21
  path: str = ""
22
22
  token: str | None = None
23
+ secure: bool = False
23
24
  timeout: float | None = None
24
25
  api_base: URL = field(init=False)
25
26
 
26
27
  def __post_init__(self):
27
28
  if self.path and not self.path.startswith("/"):
28
29
  self.path = f"/{self.path}"
29
- self.api_base = URL(f"http://{self.host}:{self.port}{self.path}") / "v1"
30
+ self.api_base = URL(f"http{'s' if self.secure else ''}://{self.host}:{self.port}{self.path}") / "v1"
30
31
 
31
32
 
32
33
  class Account(Generic[TP]):
@@ -10,6 +10,7 @@ from satori.model import (
10
10
  Channel,
11
11
  Direction,
12
12
  Event,
13
+ Friend,
13
14
  Guild,
14
15
  IterablePageResult,
15
16
  Login,
@@ -40,6 +41,7 @@ class ApiInfo(Api):
40
41
  port: int = 5140,
41
42
  path: str = "",
42
43
  token: str | None = None,
44
+ secure: bool = False,
43
45
  timeout: float | None = None,
44
46
  ):
45
47
  self.api_base: URL = ...
@@ -450,19 +452,21 @@ class Account(Generic[TP]):
450
452
  None: 该方法无返回值
451
453
  """
452
454
 
453
- async def reaction_create(self, channel_id: str, message_id: str, emoji: str) -> None:
455
+ async def reaction_create(self, channel_id: str, message_id: str, emoji_id: str) -> None:
454
456
  """向特定消息添加表态。
455
457
 
456
458
  Args:
457
459
  channel_id (str): 频道 ID
458
460
  message_id (str): 消息 ID
459
- emoji (str): 表态名称
461
+ emoji_id (str): 表情 ID
460
462
 
461
463
  Returns:
462
464
  None: 该方法无返回值
463
465
  """
464
466
 
465
- async def reaction_delete(self, channel_id: str, message_id: str, emoji: str, user_id: str | None = None) -> None:
467
+ async def reaction_delete(
468
+ self, channel_id: str, message_id: str, emoji_id: str, user_id: str | None = None
469
+ ) -> None:
466
470
  """从特定消息删除某个用户添加的特定表态。
467
471
 
468
472
  如果没有传入用户 ID 则表示删除自己的表态。
@@ -470,14 +474,14 @@ class Account(Generic[TP]):
470
474
  Args:
471
475
  channel_id (str): 频道 ID
472
476
  message_id (str): 消息 ID
473
- emoji (str): 表态名称
477
+ emoji_id (str): 表情 ID
474
478
  user_id (str | None, optional): 用户 ID,默认为 None
475
479
 
476
480
  Returns:
477
481
  None: 该方法无返回值
478
482
  """
479
483
 
480
- async def reaction_clear(self, channel_id: str, message_id: str, emoji: str | None = None) -> None:
484
+ async def reaction_clear(self, channel_id: str, message_id: str, emoji_id: str | None = None) -> None:
481
485
  """从特定消息清除某个特定表态。
482
486
 
483
487
  如果没有传入表态名称则表示清除所有表态。
@@ -485,21 +489,21 @@ class Account(Generic[TP]):
485
489
  Args:
486
490
  channel_id (str): 频道 ID
487
491
  message_id (str): 消息 ID
488
- emoji (str | None, optional): 表态名称,默认为 None
492
+ emoji_id (str | None, optional): 表情 ID,默认为 None
489
493
 
490
494
  Returns:
491
495
  None: 该方法无返回值
492
496
  """
493
497
 
494
498
  def reaction_list(
495
- self, channel_id: str, message_id: str, emoji: str, next_token: str | None = None
499
+ self, channel_id: str, message_id: str, emoji_id: str, next_token: str | None = None
496
500
  ) -> IterablePageResult[User]:
497
501
  """获取添加特定消息的特定表态的用户列表。返回一个 User 的分页列表。
498
502
 
499
503
  Args:
500
504
  channel_id (str): 频道 ID
501
505
  message_id (str): 消息 ID
502
- emoji (str): 表态名称
506
+ emoji_id (str): 表情 ID
503
507
  next_token (str | None, optional): 分页令牌,默认为空
504
508
 
505
509
  Returns:
@@ -513,24 +517,24 @@ class Account(Generic[TP]):
513
517
  Login: `Login` 对象
514
518
  """
515
519
 
516
- async def user_get(self, user_id: str) -> User:
517
- """获取用户信息。返回一个 `User` 对象。
520
+ def friend_list(self, next_token: str | None = None) -> IterablePageResult[Friend]:
521
+ """获取好友列表。返回一个 Friend 的分页列表。
518
522
 
519
523
  Args:
520
- user_id (str): 用户 ID
524
+ next_token (str | None, optional): 分页令牌,默认为空
521
525
 
522
526
  Returns:
523
- User: `User` 对象
527
+ IterablePageResult[Friend]: `Friend` 的分页列表
524
528
  """
525
529
 
526
- def friend_list(self, next_token: str | None = None) -> IterablePageResult[User]:
527
- """获取好友列表。返回一个 User 的分页列表。
530
+ async def friend_delete(self, user_id: str) -> None:
531
+ """删除好友。
528
532
 
529
533
  Args:
530
- next_token (str | None, optional): 分页令牌,默认为空
534
+ user_id (str): 用户 ID
531
535
 
532
536
  Returns:
533
- IterablePageResult[User]: `User` 的分页列表
537
+ None: 该方法无返回值
534
538
  """
535
539
 
536
540
  async def friend_approve(self, request_id: str, approve: bool, comment: str) -> None:
@@ -545,6 +549,16 @@ class Account(Generic[TP]):
545
549
  None: 该方法无返回值
546
550
  """
547
551
 
552
+ async def user_get(self, user_id: str) -> User:
553
+ """获取用户信息。返回一个 `User` 对象。
554
+
555
+ Args:
556
+ user_id (str): 用户 ID
557
+
558
+ Returns:
559
+ User: `User` 对象
560
+ """
561
+
548
562
  async def internal(self, action: str, method: str = "POST", **kwargs) -> Any:
549
563
  """内部接口调用。
550
564
 
@@ -23,6 +23,7 @@ class WebsocketsInfo(Config):
23
23
  port: int = 5140
24
24
  path: str = ""
25
25
  token: str | None = None
26
+ secure: bool = False
26
27
  timeout: float | None = None
27
28
  identity: str = None # type: ignore
28
29
  api_base: URL = None # type: ignore
@@ -31,11 +32,11 @@ class WebsocketsInfo(Config):
31
32
  if self.path and not self.path.startswith("/"):
32
33
  self.path = f"/{self.path}"
33
34
  self.identity = f"{self.host}:{self.port}"
34
- self.api_base = URL(f"http://{self.host}:{self.port}{self.path}") / "v1"
35
+ self.api_base = URL(f"http{'s' if self.secure else ''}://{self.host}:{self.port}{self.path}") / "v1"
35
36
 
36
37
  @property
37
38
  def ws_base(self):
38
- return URL(f"ws://{self.host}:{self.port}{self.path}") / "v1"
39
+ return URL(f"ws{'s' if self.secure else ''}://{self.host}:{self.port}{self.path}") / "v1"
39
40
 
40
41
 
41
42
  @dataclass
@@ -44,6 +45,7 @@ class WebhookInfo(Config):
44
45
  port: int = 8080
45
46
  path: str = "v1/events"
46
47
  token: str | None = None
48
+ secure: bool = False
47
49
  server_host: str = "localhost"
48
50
  server_port: int = 5140
49
51
  server_path: str = ""
@@ -57,4 +59,6 @@ class WebhookInfo(Config):
57
59
  if self.server_path and not self.server_path.startswith("/"):
58
60
  self.server_path = f"/{self.server_path}"
59
61
  self.identity = f"{self.host}:{self.port}{self.path}"
60
- self.api_base = URL(f"http://{self.server_host}:{self.server_port}{self.server_path}") / "v1"
62
+ self.api_base = (
63
+ URL(f"http{'s' if self.secure else ''}://{self.server_host}:{self.server_port}{self.server_path}") / "v1"
64
+ )
@@ -29,6 +29,7 @@ from satori.model import (
29
29
  User,
30
30
  )
31
31
 
32
+ from .. import Friend
32
33
  from .network.util import validate_response
33
34
 
34
35
  if TYPE_CHECKING:
@@ -632,23 +633,25 @@ class ApiProtocol:
632
633
  {"guild_id": guild_id, "role_id": role_id},
633
634
  )
634
635
 
635
- async def reaction_create(self, channel_id: str, message_id: str, emoji: str) -> None:
636
+ async def reaction_create(self, channel_id: str, message_id: str, emoji_id: str) -> None:
636
637
  """向特定消息添加表态。
637
638
 
638
639
  Args:
639
640
  channel_id (str): 频道 ID
640
641
  message_id (str): 消息 ID
641
- emoji (str): 表态名称
642
+ emoji_id (str): 表情 ID
642
643
 
643
644
  Returns:
644
645
  None: 该方法无返回值
645
646
  """
646
647
  await self.call_api(
647
648
  Api.REACTION_CREATE,
648
- {"channel_id": channel_id, "message_id": message_id, "emoji": emoji},
649
+ {"channel_id": channel_id, "message_id": message_id, "emoji_id": emoji_id},
649
650
  )
650
651
 
651
- async def reaction_delete(self, channel_id: str, message_id: str, emoji: str, user_id: str | None = None) -> None:
652
+ async def reaction_delete(
653
+ self, channel_id: str, message_id: str, emoji_id: str, user_id: str | None = None
654
+ ) -> None:
652
655
  """从特定消息删除某个用户添加的特定表态。
653
656
 
654
657
  如果没有传入用户 ID 则表示删除自己的表态。
@@ -656,13 +659,13 @@ class ApiProtocol:
656
659
  Args:
657
660
  channel_id (str): 频道 ID
658
661
  message_id (str): 消息 ID
659
- emoji (str): 表态名称
662
+ emoji_id (str): 表情 ID
660
663
  user_id (str | None, optional): 用户 ID,默认为 None
661
664
 
662
665
  Returns:
663
666
  None: 该方法无返回值
664
667
  """
665
- data = {"channel_id": channel_id, "message_id": message_id, "emoji": emoji}
668
+ data = {"channel_id": channel_id, "message_id": message_id, "emoji_id": emoji_id}
666
669
  if user_id is not None:
667
670
  data["user_id"] = user_id
668
671
  await self.call_api(
@@ -670,7 +673,7 @@ class ApiProtocol:
670
673
  data,
671
674
  )
672
675
 
673
- async def reaction_clear(self, channel_id: str, message_id: str, emoji: str | None = None) -> None:
676
+ async def reaction_clear(self, channel_id: str, message_id: str, emoji_id: str | None = None) -> None:
674
677
  """从特定消息清除某个特定表态。
675
678
 
676
679
  如果没有传入表态名称则表示清除所有表态。
@@ -678,28 +681,28 @@ class ApiProtocol:
678
681
  Args:
679
682
  channel_id (str): 频道 ID
680
683
  message_id (str): 消息 ID
681
- emoji (str | None, optional): 表态名称,默认为 None
684
+ emoji_id (str | None, optional): 表情 ID,默认为 None
682
685
 
683
686
  Returns:
684
687
  None: 该方法无返回值
685
688
  """
686
689
  data = {"channel_id": channel_id, "message_id": message_id}
687
- if emoji is not None:
688
- data["emoji"] = emoji
690
+ if emoji_id is not None:
691
+ data["emoji_id"] = emoji_id
689
692
  await self.call_api(
690
693
  Api.REACTION_CLEAR,
691
694
  data,
692
695
  )
693
696
 
694
697
  def reaction_list(
695
- self, channel_id: str, message_id: str, emoji: str, next_token: str | None = None
698
+ self, channel_id: str, message_id: str, emoji_id: str, next_token: str | None = None
696
699
  ) -> IterablePageResult[User]:
697
700
  """获取添加特定消息的特定表态的用户列表。返回一个 User 的分页列表。
698
701
 
699
702
  Args:
700
703
  channel_id (str): 频道 ID
701
704
  message_id (str): 消息 ID
702
- emoji (str): 表态名称
705
+ emoji_id (str): 表情 ID
703
706
  next_token (str | None, optional): 分页令牌,默认为空
704
707
 
705
708
  Returns:
@@ -712,7 +715,7 @@ class ApiProtocol:
712
715
  {
713
716
  "channel_id": channel_id,
714
717
  "message_id": message_id,
715
- "emoji": emoji,
718
+ "emoji_id": emoji_id,
716
719
  "next": token,
717
720
  },
718
721
  )
@@ -729,34 +732,33 @@ class ApiProtocol:
729
732
  res = await self.call_api(Api.LOGIN_GET, {})
730
733
  return Login.parse(res)
731
734
 
732
- async def user_get(self, user_id: str) -> User:
733
- """获取用户信息。返回一个 `User` 对象。
734
-
735
- Args:
736
- user_id (str): 用户 ID
737
-
738
- Returns:
739
- User: `User` 对象
740
- """
741
- res = await self.call_api(Api.USER_GET, {"user_id": user_id})
742
- return User.parse(res)
743
-
744
- def friend_list(self, next_token: str | None = None) -> IterablePageResult[User]:
735
+ def friend_list(self, next_token: str | None = None) -> IterablePageResult[Friend]:
745
736
  """获取好友列表。返回一个 User 的分页列表。
746
737
 
747
738
  Args:
748
739
  next_token (str | None, optional): 分页令牌,默认为空
749
740
 
750
741
  Returns:
751
- IterablePageResult[User]: `User` 的分页列表
742
+ IterablePageResult[Friend]: `Friend` 的分页列表
752
743
  """
753
744
 
754
745
  async def _(token: str | None):
755
746
  res = await self.call_api(Api.FRIEND_LIST, {"next": token})
756
- return PageResult.parse(res, User.parse)
747
+ return PageResult.parse(res, Friend.parse)
757
748
 
758
749
  return IterablePageResult(_, next_token)
759
750
 
751
+ async def friend_delete(self, user_id: str) -> None:
752
+ """删除好友。
753
+
754
+ Args:
755
+ user_id (str): 用户 ID
756
+
757
+ Returns:
758
+ None: 该方法无返回值
759
+ """
760
+ await self.call_api(Api.FRIEND_DELETE, {"user_id": user_id})
761
+
760
762
  async def friend_approve(self, request_id: str, approve: bool, comment: str) -> None:
761
763
  """处理好友申请。
762
764
 
@@ -773,6 +775,18 @@ class ApiProtocol:
773
775
  {"message_id": request_id, "approve": approve, "comment": comment},
774
776
  )
775
777
 
778
+ async def user_get(self, user_id: str) -> User:
779
+ """获取用户信息。返回一个 `User` 对象。
780
+
781
+ Args:
782
+ user_id (str): 用户 ID
783
+
784
+ Returns:
785
+ User: `User` 对象
786
+ """
787
+ res = await self.call_api(Api.USER_GET, {"user_id": user_id})
788
+ return User.parse(res)
789
+
776
790
  async def internal(self, action: str, method: str = "POST", **kwargs) -> Any:
777
791
  """内部接口调用。
778
792