nonebot-plugin-werewolf 1.1.2__tar.gz → 1.1.5__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.
Files changed (43) hide show
  1. {nonebot_plugin_werewolf-1.1.2/nonebot_plugin_werewolf.egg-info → nonebot_plugin_werewolf-1.1.5}/PKG-INFO +24 -4
  2. nonebot_plugin_werewolf-1.1.2/PKG-INFO → nonebot_plugin_werewolf-1.1.5/README.md +18 -16
  3. {nonebot_plugin_werewolf-1.1.2 → nonebot_plugin_werewolf-1.1.5}/nonebot_plugin_werewolf/__init__.py +9 -4
  4. {nonebot_plugin_werewolf-1.1.2 → nonebot_plugin_werewolf-1.1.5}/nonebot_plugin_werewolf/config.py +11 -15
  5. {nonebot_plugin_werewolf-1.1.2 → nonebot_plugin_werewolf-1.1.5}/nonebot_plugin_werewolf/constant.py +40 -3
  6. {nonebot_plugin_werewolf-1.1.2 → nonebot_plugin_werewolf-1.1.5}/nonebot_plugin_werewolf/game.py +219 -181
  7. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/matchers/__init__.py +2 -0
  8. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/matchers/depends.py +38 -0
  9. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/matchers/message_in_game.py +25 -0
  10. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/matchers/poke/__init__.py +8 -0
  11. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/matchers/poke/chronocat_poke.py +117 -0
  12. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/matchers/poke/ob11_poke.py +80 -0
  13. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/matchers/start_game.py +202 -0
  14. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/player_set.py +84 -0
  15. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/players/__init__.py +10 -0
  16. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/players/can_shoot.py +53 -0
  17. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/players/civilian.py +7 -0
  18. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/players/guard.py +30 -0
  19. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/players/hunter.py +8 -0
  20. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/players/idiot.py +44 -0
  21. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/players/joker.py +21 -0
  22. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/players/player.py +233 -0
  23. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/players/prophet.py +22 -0
  24. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/players/werewolf.py +89 -0
  25. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/players/witch.py +66 -0
  26. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/players/wolfking.py +14 -0
  27. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/utils.py +86 -0
  28. nonebot_plugin_werewolf-1.1.2/README.md → nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf.egg-info/PKG-INFO +36 -2
  29. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf.egg-info/SOURCES.txt +34 -0
  30. {nonebot_plugin_werewolf-1.1.2 → nonebot_plugin_werewolf-1.1.5}/nonebot_plugin_werewolf.egg-info/requires.txt +2 -1
  31. {nonebot_plugin_werewolf-1.1.2 → nonebot_plugin_werewolf-1.1.5}/pyproject.toml +10 -2
  32. nonebot_plugin_werewolf-1.1.2/nonebot_plugin_werewolf/_timeout.py +0 -110
  33. nonebot_plugin_werewolf-1.1.2/nonebot_plugin_werewolf/matchers.py +0 -62
  34. nonebot_plugin_werewolf-1.1.2/nonebot_plugin_werewolf/ob11_ext.py +0 -72
  35. nonebot_plugin_werewolf-1.1.2/nonebot_plugin_werewolf/player.py +0 -462
  36. nonebot_plugin_werewolf-1.1.2/nonebot_plugin_werewolf/player_set.py +0 -83
  37. nonebot_plugin_werewolf-1.1.2/nonebot_plugin_werewolf/utils.py +0 -201
  38. nonebot_plugin_werewolf-1.1.2/nonebot_plugin_werewolf.egg-info/SOURCES.txt +0 -19
  39. {nonebot_plugin_werewolf-1.1.2 → nonebot_plugin_werewolf-1.1.5}/LICENSE +0 -0
  40. {nonebot_plugin_werewolf-1.1.2 → nonebot_plugin_werewolf-1.1.5}/nonebot_plugin_werewolf/exception.py +0 -0
  41. {nonebot_plugin_werewolf-1.1.2 → nonebot_plugin_werewolf-1.1.5}/nonebot_plugin_werewolf.egg-info/dependency_links.txt +0 -0
  42. {nonebot_plugin_werewolf-1.1.2 → nonebot_plugin_werewolf-1.1.5}/nonebot_plugin_werewolf.egg-info/top_level.txt +0 -0
  43. {nonebot_plugin_werewolf-1.1.2 → nonebot_plugin_werewolf-1.1.5}/setup.cfg +0 -0
@@ -1,16 +1,20 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-werewolf
3
- Version: 1.1.2
3
+ Version: 1.1.5
4
4
  Summary: 适用于 Nonebot2 的狼人杀插件
5
5
  Author-email: wyf7685 <wyf7685@163.com>
6
6
  License: MIT
7
+ Project-URL: homepage, https://github.com/wyf7685/nonebot-plugin-werewolf
8
+ Project-URL: repository, https://github.com/wyf7685/nonebot-plugin-werewolf
9
+ Project-URL: bug-tracker, https://github.com/wyf7685/nonebot-plugin-werewolf/issues
7
10
  Requires-Python: >=3.10
8
11
  Description-Content-Type: text/markdown
9
12
  License-File: LICENSE
10
13
  Requires-Dist: nonebot2>=2.3.3
11
14
  Requires-Dist: nonebot-plugin-alconna>=0.52.1
12
- Requires-Dist: nonebot-plugin-userinfo>=0.2.6
15
+ Requires-Dist: nonebot-plugin-uninfo>=0.4.0
13
16
  Requires-Dist: nonebot-plugin-waiter>=0.7.1
17
+ Requires-Dist: anyio>=4.6.0
14
18
 
15
19
  <div align="center">
16
20
  <a href="https://v2.nonebot.dev/store">
@@ -39,6 +43,7 @@ _✨ 简单的狼人杀插件 ✨_
39
43
  [![pyright](https://github.com/wyf7685/nonebot-plugin-werewolf/actions/workflows/pyright.yml/badge.svg?branch=master&event=push)](https://github.com/wyf7685/nonebot-plugin-werewolf/actions/workflows/pyright.yml)
40
44
  [![publish](https://github.com/wyf7685/nonebot-plugin-werewolf/actions/workflows/pypi-publish.yml/badge.svg)](https://github.com/wyf7685/nonebot-plugin-werewolf/actions/workflows/pypi-publish.yml)
41
45
 
46
+ <!-- https://github.com/lgc2333/nonebot-registry-badge -->
42
47
  [![NoneBot Registry](https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin%2Fnonebot-plugin-werewolf)](https://registry.nonebot.dev/plugin/nonebot-plugin-werewolf:nonebot_plugin_werewolf)
43
48
  [![Supported Adapters](https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin-adapters%2Fnonebot-plugin-werewolf)](https://registry.nonebot.dev/plugin/nonebot-plugin-werewolf:nonebot_plugin_werewolf)
44
49
 
@@ -145,7 +150,7 @@ _✨ 简单的狼人杀插件 ✨_
145
150
 
146
151
  _其他交互参考游戏内提示_
147
152
 
148
- 对于 `OneBot V11` 适配器, 启用配置项 `werewolf__enable_poke` 后, 可以使用戳一戳代替 _准备阶段_ 的 `加入游戏` 操作 和 游戏内的 `/stop` 命令
153
+ 对于 `OneBot V11` 适配器和 `Satori` 适配器的 `chronocat`, 启用配置项 `werewolf__enable_poke` 后, 可以使用戳一戳代替 _准备阶段_ 的 `加入游戏` 操作 和 游戏内的 `stop` 命令
149
154
 
150
155
  ### 游戏内容
151
156
 
@@ -233,6 +238,10 @@ werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
233
238
 
234
239
  </details>
235
240
 
241
+ ### 已知问题
242
+
243
+ - 截止 chronocat v0.2.19, 调用 [`guild.member.get`](https://github.com/chrononeko/chronocat/blob/8558ad9ff4319395d86abbfda22136939bf66780/packages/engine-chronocat-api/src/api/guild/member/get.ts) / [`user.get`](https://github.com/chrononeko/chronocat/blob/8558ad9ff4319395d86abbfda22136939bf66780/packages/engine-chronocat-api/src/api/user/get.ts) 均无法获取用户名,这将导致在交互过程中的玩家名显示为用户ID
244
+
236
245
  ## 📝 更新日志
237
246
 
238
247
  <details>
@@ -240,6 +249,17 @@ werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
240
249
 
241
250
  <!-- CHANGELOG -->
242
251
 
252
+ - 2024.10.23 v1.1.5
253
+
254
+ - 添加对 chronocat:poke 的支持
255
+ - 游戏内 stop 命令使用 COMMAND_START
256
+ - 使用 `anyio` 重写并发逻辑
257
+
258
+ - 2024.10.06 v1.1.3
259
+
260
+ - 使用 `RF-Tar-Railt/nonebot-plugin-uninfo` 获取用户数据
261
+ - 优化交互文本
262
+
243
263
  - 2024.09.18 v1.1.2
244
264
 
245
265
  - 修改 Python 需求为 `>=3.10`
@@ -284,6 +304,6 @@ werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
284
304
 
285
305
  - [`nonebot/nonebot2`](https://github.com/nonebot/nonebot2): 跨平台 Python 异步机器人框架
286
306
  - [`nonebot/plugin-alconna`](https://github.com/nonebot/plugin-alconna): 跨平台的消息处理接口
287
- - [`noneplugin/nonebot-plugin-userinfo`](https://github.com/noneplugin/nonebot-plugin-userinfo): 用户信息获取
307
+ - [`RF-Tar-Railt/nonebot-plugin-uninfo`](https://github.com/RF-Tar-Railt/nonebot-plugin-uninfo): 用户信息获取
288
308
  - [`RF-Tar-Railt/nonebot-plugin-waiter`](https://github.com/RF-Tar-Railt/nonebot-plugin-waiter): 灵活获取用户输入
289
309
  - `热心群友`: 协助测试插件
@@ -1,17 +1,3 @@
1
- Metadata-Version: 2.1
2
- Name: nonebot-plugin-werewolf
3
- Version: 1.1.2
4
- Summary: 适用于 Nonebot2 的狼人杀插件
5
- Author-email: wyf7685 <wyf7685@163.com>
6
- License: MIT
7
- Requires-Python: >=3.10
8
- Description-Content-Type: text/markdown
9
- License-File: LICENSE
10
- Requires-Dist: nonebot2>=2.3.3
11
- Requires-Dist: nonebot-plugin-alconna>=0.52.1
12
- Requires-Dist: nonebot-plugin-userinfo>=0.2.6
13
- Requires-Dist: nonebot-plugin-waiter>=0.7.1
14
-
15
1
  <div align="center">
16
2
  <a href="https://v2.nonebot.dev/store">
17
3
  <img src="https://raw.githubusercontent.com/wyf7685/wyf7685/main/assets/NoneBotPlugin.svg" width="300" alt="logo">
@@ -39,6 +25,7 @@ _✨ 简单的狼人杀插件 ✨_
39
25
  [![pyright](https://github.com/wyf7685/nonebot-plugin-werewolf/actions/workflows/pyright.yml/badge.svg?branch=master&event=push)](https://github.com/wyf7685/nonebot-plugin-werewolf/actions/workflows/pyright.yml)
40
26
  [![publish](https://github.com/wyf7685/nonebot-plugin-werewolf/actions/workflows/pypi-publish.yml/badge.svg)](https://github.com/wyf7685/nonebot-plugin-werewolf/actions/workflows/pypi-publish.yml)
41
27
 
28
+ <!-- https://github.com/lgc2333/nonebot-registry-badge -->
42
29
  [![NoneBot Registry](https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin%2Fnonebot-plugin-werewolf)](https://registry.nonebot.dev/plugin/nonebot-plugin-werewolf:nonebot_plugin_werewolf)
43
30
  [![Supported Adapters](https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin-adapters%2Fnonebot-plugin-werewolf)](https://registry.nonebot.dev/plugin/nonebot-plugin-werewolf:nonebot_plugin_werewolf)
44
31
 
@@ -145,7 +132,7 @@ _✨ 简单的狼人杀插件 ✨_
145
132
 
146
133
  _其他交互参考游戏内提示_
147
134
 
148
- 对于 `OneBot V11` 适配器, 启用配置项 `werewolf__enable_poke` 后, 可以使用戳一戳代替 _准备阶段_ 的 `加入游戏` 操作 和 游戏内的 `/stop` 命令
135
+ 对于 `OneBot V11` 适配器和 `Satori` 适配器的 `chronocat`, 启用配置项 `werewolf__enable_poke` 后, 可以使用戳一戳代替 _准备阶段_ 的 `加入游戏` 操作 和 游戏内的 `stop` 命令
149
136
 
150
137
  ### 游戏内容
151
138
 
@@ -233,6 +220,10 @@ werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
233
220
 
234
221
  </details>
235
222
 
223
+ ### 已知问题
224
+
225
+ - 截止 chronocat v0.2.19, 调用 [`guild.member.get`](https://github.com/chrononeko/chronocat/blob/8558ad9ff4319395d86abbfda22136939bf66780/packages/engine-chronocat-api/src/api/guild/member/get.ts) / [`user.get`](https://github.com/chrononeko/chronocat/blob/8558ad9ff4319395d86abbfda22136939bf66780/packages/engine-chronocat-api/src/api/user/get.ts) 均无法获取用户名,这将导致在交互过程中的玩家名显示为用户ID
226
+
236
227
  ## 📝 更新日志
237
228
 
238
229
  <details>
@@ -240,6 +231,17 @@ werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
240
231
 
241
232
  <!-- CHANGELOG -->
242
233
 
234
+ - 2024.10.23 v1.1.5
235
+
236
+ - 添加对 chronocat:poke 的支持
237
+ - 游戏内 stop 命令使用 COMMAND_START
238
+ - 使用 `anyio` 重写并发逻辑
239
+
240
+ - 2024.10.06 v1.1.3
241
+
242
+ - 使用 `RF-Tar-Railt/nonebot-plugin-uninfo` 获取用户数据
243
+ - 优化交互文本
244
+
243
245
  - 2024.09.18 v1.1.2
244
246
 
245
247
  - 修改 Python 需求为 `>=3.10`
@@ -284,6 +286,6 @@ werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
284
286
 
285
287
  - [`nonebot/nonebot2`](https://github.com/nonebot/nonebot2): 跨平台 Python 异步机器人框架
286
288
  - [`nonebot/plugin-alconna`](https://github.com/nonebot/plugin-alconna): 跨平台的消息处理接口
287
- - [`noneplugin/nonebot-plugin-userinfo`](https://github.com/noneplugin/nonebot-plugin-userinfo): 用户信息获取
289
+ - [`RF-Tar-Railt/nonebot-plugin-uninfo`](https://github.com/RF-Tar-Railt/nonebot-plugin-uninfo): 用户信息获取
288
290
  - [`RF-Tar-Railt/nonebot-plugin-waiter`](https://github.com/RF-Tar-Railt/nonebot-plugin-waiter): 灵活获取用户输入
289
291
  - `热心群友`: 协助测试插件
@@ -2,13 +2,14 @@ from nonebot import require
2
2
  from nonebot.plugin import PluginMetadata, inherit_supported_adapters
3
3
 
4
4
  require("nonebot_plugin_alconna")
5
- require("nonebot_plugin_userinfo")
5
+ require("nonebot_plugin_uninfo")
6
6
  require("nonebot_plugin_waiter")
7
7
 
8
8
  from . import matchers as matchers
9
+ from . import players as players
9
10
  from .config import Config
10
11
 
11
- __version__ = "1.1.2"
12
+ __version__ = "1.1.5"
12
13
  __plugin_meta__ = PluginMetadata(
13
14
  name="狼人杀",
14
15
  description="适用于 Nonebot2 的狼人杀插件",
@@ -18,8 +19,12 @@ __plugin_meta__ = PluginMetadata(
18
19
  config=Config,
19
20
  supported_adapters=inherit_supported_adapters(
20
21
  "nonebot_plugin_alconna",
21
- "nonebot_plugin_userinfo",
22
+ "nonebot_plugin_uninfo",
22
23
  "nonebot_plugin_waiter",
23
24
  ),
24
- extra={"author": "wyf7685"},
25
+ extra={
26
+ "Author": "wyf7685",
27
+ "Version": __version__,
28
+ "Bug Tracker": "https://github.com/wyf7685/nonebot-plugin-werewolf/issues",
29
+ },
25
30
  )
@@ -1,4 +1,4 @@
1
- from typing import Literal, overload
1
+ from typing import Any, Literal, overload
2
2
 
3
3
  from nonebot import get_plugin_config, logger
4
4
  from nonebot.compat import PYDANTIC_V2
@@ -7,6 +7,8 @@ from typing_extensions import Self
7
7
 
8
8
  from .constant import (
9
9
  Role,
10
+ RolePresetConfig,
11
+ RolePresetDict,
10
12
  default_priesthood_proirity,
11
13
  default_role_preset,
12
14
  default_werewolf_priority,
@@ -18,12 +20,12 @@ else:
18
20
  from pydantic import root_validator
19
21
 
20
22
  @overload
21
- def model_validator(*, mode: Literal["before"]): ... # noqa: ANN201
23
+ def model_validator(*, mode: Literal["before"]) -> Any: ... # noqa: ANN401
22
24
 
23
25
  @overload
24
- def model_validator(*, mode: Literal["after"]): ... # noqa: ANN201
26
+ def model_validator(*, mode: Literal["after"]) -> Any: ... # noqa: ANN401
25
27
 
26
- def model_validator(*, mode: Literal["before", "after"]):
28
+ def model_validator(*, mode: Literal["before", "after"]) -> Any:
27
29
  return root_validator(
28
30
  pre=mode == "before", # pyright: ignore[reportArgumentType]
29
31
  allow_reuse=True,
@@ -31,16 +33,10 @@ else:
31
33
 
32
34
 
33
35
  class PluginConfig(BaseModel):
34
- enable_poke: bool = Field(default=True)
35
- role_preset: list[tuple[int, int, int, int]] | dict[int, tuple[int, int, int]] = (
36
- Field(default_factory=default_role_preset.copy)
37
- )
38
- werewolf_priority: list[Role] = Field(
39
- default_factory=default_werewolf_priority.copy
40
- )
41
- priesthood_proirity: list[Role] = Field(
42
- default_factory=default_priesthood_proirity.copy
43
- )
36
+ enable_poke: bool = True
37
+ role_preset: RolePresetConfig = default_role_preset.copy()
38
+ werewolf_priority: list[Role] = default_werewolf_priority.copy()
39
+ priesthood_proirity: list[Role] = default_priesthood_proirity.copy()
44
40
  joker_probability: float = Field(default=0.0, ge=0.0, le=1.0)
45
41
 
46
42
  @model_validator(mode="after")
@@ -72,7 +68,7 @@ class PluginConfig(BaseModel):
72
68
 
73
69
  return self
74
70
 
75
- def get_role_preset(self) -> dict[int, tuple[int, int, int]]:
71
+ def get_role_preset(self) -> RolePresetDict:
76
72
  if isinstance(self.role_preset, list):
77
73
  self.role_preset = {i[0]: i[1:] for i in self.role_preset}
78
74
  return self.role_preset
@@ -4,8 +4,17 @@ import dataclasses
4
4
  from enum import Enum, auto
5
5
  from typing import TYPE_CHECKING
6
6
 
7
+ import nonebot
8
+
7
9
  if TYPE_CHECKING:
8
- from .player import Player
10
+ from .players import Player
11
+
12
+
13
+ COMMAND_START = next(
14
+ iter(sorted(nonebot.get_driver().config.command_start, key=len)), ""
15
+ )
16
+ STOP_COMMAND_PROMPT = f"{COMMAND_START}stop"
17
+ STOP_COMMAND = "{{stop}}"
9
18
 
10
19
 
11
20
  class Role(Enum):
@@ -49,11 +58,24 @@ class GameStatus(Enum):
49
58
  @dataclasses.dataclass
50
59
  class GameState:
51
60
  day: int
61
+ """当前天数记录, 不会被 `reset()` 重置"""
52
62
  killed: Player | None = None
53
- shoot: tuple[Player, Player] | tuple[None, None] = (None, None)
63
+ """当晚狼人击杀目标, `None` 则为空刀"""
64
+ shoot: Player | None = None
65
+ """当前执行射杀操作的玩家"""
54
66
  antidote: set[Player] = dataclasses.field(default_factory=set)
67
+ """当晚女巫使用解药的目标"""
55
68
  poison: set[Player] = dataclasses.field(default_factory=set)
69
+ """当晚使用了毒药的女巫"""
56
70
  protected: set[Player] = dataclasses.field(default_factory=set)
71
+ """当晚守卫保护的目标"""
72
+
73
+ def reset(self) -> None:
74
+ self.killed = None
75
+ self.shoot = None
76
+ self.antidote = set()
77
+ self.poison = set()
78
+ self.protected = set()
57
79
 
58
80
 
59
81
  role_name_conv: dict[Role | RoleGroup, str] = {
@@ -71,7 +93,22 @@ role_name_conv: dict[Role | RoleGroup, str] = {
71
93
  RoleGroup.Others: "其他",
72
94
  }
73
95
 
74
- default_role_preset: dict[int, tuple[int, int, int]] = {
96
+ role_emoji: dict[Role, str] = {
97
+ Role.Werewolf: "🐺",
98
+ Role.WolfKing: "🐺👑",
99
+ Role.Prophet: "🔮",
100
+ Role.Witch: "🧙‍♀️",
101
+ Role.Hunter: "🕵️",
102
+ Role.Guard: "🛡️",
103
+ Role.Idiot: "👨🏻‍🦲",
104
+ Role.Joker: "🤡",
105
+ Role.Civilian: "👨🏻‍🌾",
106
+ }
107
+
108
+ RolePresetDict = dict[int, tuple[int, int, int]]
109
+ RolePresetConfig = RolePresetDict | list[tuple[int, int, int, int]]
110
+
111
+ default_role_preset: RolePresetDict = {
75
112
  # 总人数: (狼, 神, 民)
76
113
  6: (1, 2, 3),
77
114
  7: (2, 2, 3),