nonebot-plugin-werewolf 1.1.12__py3-none-any.whl → 1.1.13__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.
@@ -10,7 +10,7 @@ from . import matchers as matchers
10
10
  from . import players as players
11
11
  from .config import Config
12
12
 
13
- __version__ = "1.1.12"
13
+ __version__ = "1.1.13"
14
14
  __plugin_meta__ = PluginMetadata(
15
15
  name="狼人杀",
16
16
  description="适用于 Nonebot2 的狼人杀插件",
@@ -1,10 +1,11 @@
1
1
  import json
2
+ import warnings
2
3
  from pathlib import Path
3
4
  from typing import Any, ClassVar, Final, Literal
4
5
  from typing_extensions import Self
5
6
 
6
7
  import nonebot
7
- from nonebot.compat import model_dump, type_validate_json
8
+ from nonebot.compat import model_dump, model_validator, type_validate_json
8
9
  from nonebot_plugin_localstore import get_plugin_data_file
9
10
  from pydantic import BaseModel, Field
10
11
 
@@ -90,7 +91,18 @@ class MatcherPriorityConfig(BaseModel):
90
91
  preset: int = 1
91
92
  behavior: int = 1
92
93
  in_game: int = 10
93
- stop: int = 10
94
+ stop: int = 9
95
+
96
+ @model_validator(mode="after")
97
+ @classmethod
98
+ def _validate(cls, model: Self) -> Self:
99
+ if model.in_game <= model.stop:
100
+ model.in_game = model.stop + 1
101
+ warnings.warn(
102
+ "in_game 的优先级必须低于 stop,已自动调整为 stop + 1",
103
+ stacklevel=2,
104
+ )
105
+ return model
94
106
 
95
107
 
96
108
  class PluginConfig(BaseModel):
@@ -99,6 +111,7 @@ class PluginConfig(BaseModel):
99
111
  stop_command: str | set[str] = "stop"
100
112
  require_at: bool | RequireAtConfig = True
101
113
  matcher_priority: MatcherPriorityConfig = MatcherPriorityConfig()
114
+ use_cmd_start: bool | None = None
102
115
 
103
116
  def get_stop_command(self) -> list[str]:
104
117
  return (
@@ -118,6 +118,7 @@ alc = Alconna(
118
118
  edit_behavior = on_alconna(
119
119
  alc,
120
120
  permission=SUPERUSER,
121
+ use_cmd_start=config.use_cmd_start,
121
122
  priority=config.matcher_priority.behavior,
122
123
  )
123
124
 
@@ -72,6 +72,7 @@ alc = Alconna(
72
72
  edit_preset = on_alconna(
73
73
  alc,
74
74
  permission=SUPERUSER,
75
+ use_cmd_start=config.use_cmd_start,
75
76
  priority=config.matcher_priority.preset,
76
77
  )
77
78
 
@@ -25,8 +25,8 @@ stopcmd = on_alconna(
25
25
  Alconna(config.get_stop_command()[0]),
26
26
  rule=rule_in_game,
27
27
  block=True,
28
- use_cmd_start=True,
29
28
  aliases=set(aliases) if (aliases := config.get_stop_command()[1:]) else None,
29
+ use_cmd_start=config.use_cmd_start,
30
30
  priority=config.matcher_priority.stop,
31
31
  )
32
32
 
@@ -32,6 +32,7 @@ start_game = on_alconna(
32
32
  if config.get_require_at("start")
33
33
  else rule_not_in_game,
34
34
  aliases={"狼人杀"},
35
+ use_cmd_start=config.use_cmd_start,
35
36
  priority=config.matcher_priority.start,
36
37
  )
37
38
  player_data_file = get_plugin_data_file("players.json")
@@ -12,6 +12,7 @@ terminate = on_alconna(
12
12
  Alconna("中止游戏"),
13
13
  rule=to_me() if config.get_require_at("terminate") else None,
14
14
  permission=SUPERUSER,
15
+ use_cmd_start=config.use_cmd_start,
15
16
  priority=config.matcher_priority.terminate,
16
17
  )
17
18
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nonebot-plugin-werewolf
3
- Version: 1.1.12
3
+ Version: 1.1.13
4
4
  Summary: 适用于 Nonebot2 的狼人杀插件
5
5
  Author-email: wyf7685 <wyf7685@163.com>
6
6
  License: MIT
@@ -53,7 +53,8 @@ _✨ 简单的狼人杀插件 ✨_
53
53
  <!-- ref: https://github.com/KomoriDev/Starify -->
54
54
 
55
55
  > [!IMPORTANT]
56
- > **收藏项目**,你将从 GitHub 上无延迟地接收所有发布通知~⭐️
56
+ >
57
+ > **收藏项目**,你将从 GitHub 上无延迟地接收所有发布通知~ ⭐️
57
58
 
58
59
  <img width="100%" src="https://starify.komoridevs.icu/api/starify?owner=wyf7685&repo=nonebot-plugin-werewolf" alt="starify" />
59
60
 
@@ -126,13 +127,14 @@ _✨ 简单的狼人杀插件 ✨_
126
127
 
127
128
  在 nonebot2 项目的 `.env` 文件中添加如下配置:
128
129
 
129
- | 配置项 | 必填 | 默认值 | 类型 | 说明 |
130
- | :--------------------------: | :--: | :-----: | :-----------------------: | :----------------------------: |
131
- | `werewolf__enable_poke` | 否 | `True` | `bool` | 是否使用戳一戳简化操作流程 |
132
- | `werewolf__enable_button` | 否 | `False` | `bool` | 是否在交互中添加按钮 |
133
- | `werewolf__stop_command` | 否 | `stop` | `str \| set[str]` | 修改游戏进程中的 `stop` 命令 |
134
- | `werewolf__require_at` | 否 | `True` | `bool \| RequireAtConfig` | 部分命令是否需要 at 机器人触发 |
135
- | `werewolf__matcher_priority` | 否 | - | `MatcherPriorityConfig` | 配置插件 matcher 注册的优先级 |
130
+ | 配置项 | 必填 | 默认值 | 类型 | 说明 |
131
+ | :--------------------------: | :--: | :-----: | :-----------------------: | :-------------------------------------------: |
132
+ | `werewolf__enable_poke` | 否 | `True` | `bool` | 是否使用戳一戳简化操作流程 |
133
+ | `werewolf__enable_button` | 否 | `False` | `bool` | 是否在交互中添加按钮 |
134
+ | `werewolf__stop_command` | 否 | `stop` | `str \| set[str]` | 修改游戏进程中的 `stop` 命令 |
135
+ | `werewolf__require_at` | 否 | `True` | `bool \| RequireAtConfig` | 部分命令是否需要 at 机器人触发 |
136
+ | `werewolf__matcher_priority` | 否 | - | `MatcherPriorityConfig` | 配置插件 matcher 注册的优先级 |
137
+ | `werewolf__use_cmd_start` | 否 | `None` | `bool \| None` | 是否使用配置项 `COMMAND_START` 来作为命令前缀 |
136
138
 
137
139
  `werewolf__enable_poke` 仅在 `OneBot V11` 适配器 / `Satori/chronocat` 下生效
138
140
 
@@ -160,6 +162,8 @@ werewolf__require_at='{"start": true, "terminate": false}'
160
162
  - 如果遇到与其他插件的命令冲突, 可考虑修改此处的优先级配置
161
163
  - 配置应填入 JSON 对象, 可用键: `start` `terminate` `preset` `behavior` `in_game` `stop`
162
164
 
165
+ `werewolf__use_cmd_start` 为 `None` 时,使用 alc 的 [全局配置](https://nonebot.dev/docs/next/best-practice/alconna/config#alconna_use_command_start)
166
+
163
167
  ## 🚀 使用
164
168
 
165
169
  > [!note]
@@ -295,6 +299,11 @@ werewolf__require_at='{"start": true, "terminate": false}'
295
299
 
296
300
  <!-- CHANGELOG -->
297
301
 
302
+ - 2025.06.04 v1.1.13
303
+
304
+ - 添加配置项 `werewolf__use_cmd_start`, 用于配置插件命令前缀
305
+ - 调整 v1.1.11 优先级配置的默认值
306
+
298
307
  - 2025.06.01 v1.1.12
299
308
 
300
309
  - 禁用 `discord` 适配器中的按钮操作 ~~以后会写适配的...吗?~~
@@ -1,5 +1,5 @@
1
- nonebot_plugin_werewolf/__init__.py,sha256=i29POIWhdp2Ev3yu8Q5IFgxEi8jYTqsVbSY1IuggAew,932
2
- nonebot_plugin_werewolf/config.py,sha256=EVitkkXL4Dv_LfePjknCa2uoeYt-e6aw_CRzTMbaEhQ,3736
1
+ nonebot_plugin_werewolf/__init__.py,sha256=cj9lzoACNyphf7iZF5PkD9jxaMUzxQWYG_GE5cb649k,932
2
+ nonebot_plugin_werewolf/config.py,sha256=fZ8xvEsjBxLZQjbYMvLA3CbGq0EAEj6JKSGe111ectM,4166
3
3
  nonebot_plugin_werewolf/constant.py,sha256=DqGgUfzsXt1Ls0tTHSSaYrUOZNuv6lgjfhfvdLR5DoM,1641
4
4
  nonebot_plugin_werewolf/dead_channel.py,sha256=Dzs9E-jU_alZgCnZzFbvJwgIXrSHSxyNy1yLb_6-0Oo,2720
5
5
  nonebot_plugin_werewolf/exception.py,sha256=SP9RdzsREB6PtpRfhZjxqybtvO0aw48hpN9QMU9jDZY,366
@@ -11,11 +11,11 @@ nonebot_plugin_werewolf/utils.py,sha256=V3JcguIHFxyOhkGE4vbc5Sd5g4oJAzxs69bLHuO-
11
11
  nonebot_plugin_werewolf/matchers/__init__.py,sha256=lQ9AZDEWgtbP-W8KWvjkEYc_UfTHSUwjaGdZ7PT3z0E,219
12
12
  nonebot_plugin_werewolf/matchers/_prepare_game.py,sha256=Cmzffbo79ecIJFzhTeOY8isOK7mvVJZr02AV7Zt-aBE,7855
13
13
  nonebot_plugin_werewolf/matchers/depends.py,sha256=DVc9Ewzja9ywJ8MyYxST8pnfpVNJhLXafhbZhEMuxt8,1350
14
- nonebot_plugin_werewolf/matchers/edit_behavior.py,sha256=8gTSnvJNqKGjmOts_5zYR4f5Qn-NxUlAvUsOCk6LYDw,7262
15
- nonebot_plugin_werewolf/matchers/edit_preset.py,sha256=DXd5v9TtpwCGxqhivUgz2AqwXSE9evE0lc2Z7OrEjV8,8056
16
- nonebot_plugin_werewolf/matchers/message_in_game.py,sha256=xpnUanxa-reVlaXnwBTwfoDWQc-MhsMq03tHFKjeEkQ,1052
17
- nonebot_plugin_werewolf/matchers/start_game.py,sha256=fYOPdxnE9xe9wr8tSecvypXF-ZwqZnNPNyNH2x8M7ws,4069
18
- nonebot_plugin_werewolf/matchers/superuser_ops.py,sha256=KLl1cJHogk3DAtEXfu_r-iqA6kggwE5lNVPuyZNyHos,833
14
+ nonebot_plugin_werewolf/matchers/edit_behavior.py,sha256=cm_DtoyEhB1xujQiSrZd1uGaRfFjDl5lHsekaxJUKX0,7302
15
+ nonebot_plugin_werewolf/matchers/edit_preset.py,sha256=Qn0jb3l0HbpuH1FWN8yklpbCPp-W8LKwOkfw-rtKNeM,8096
16
+ nonebot_plugin_werewolf/matchers/message_in_game.py,sha256=3MYY1v9nkrbF-l-cJAoDzpmwvBCyb_QPumwuRPme_kY,1068
17
+ nonebot_plugin_werewolf/matchers/start_game.py,sha256=Dg2N615UxiE6qKux70flKo642OdTwg3QlivoyMIZUwk,4109
18
+ nonebot_plugin_werewolf/matchers/superuser_ops.py,sha256=urYaVsnd-Sx-h5ha0XDI62vHeiOfpwIptWp6ZP0UKqQ,873
19
19
  nonebot_plugin_werewolf/matchers/poke/__init__.py,sha256=LhWYvAYZsmJbnYMFj7Q032pvq5_P6FYRCzvnwuBvsb0,272
20
20
  nonebot_plugin_werewolf/matchers/poke/chronocat_poke.py,sha256=FEelbSnx8-44K3G24Zv059fxei1MjrnZaaUtlTUb7lc,3934
21
21
  nonebot_plugin_werewolf/matchers/poke/ob11_poke.py,sha256=fnRiy7INcz0Y_Awqd-J0wW2taXABHIDUfluE9rgAzw8,2542
@@ -30,8 +30,8 @@ nonebot_plugin_werewolf/players/shooter.py,sha256=XtTKspxodeqYwnxtBIwmgxaQEDXcfC
30
30
  nonebot_plugin_werewolf/players/werewolf.py,sha256=M-_OZ_E2drx7I0G7Ld8FJ7QjaRfAxOCCnI6YL4SDWYw,5325
31
31
  nonebot_plugin_werewolf/players/witch.py,sha256=5qeWI1FOi3iUuzMhuTSJVo8Izc0KHseMKvncucvRFSE,3041
32
32
  nonebot_plugin_werewolf/players/wolfking.py,sha256=CMZ5Tq74wupcRPjAzXHEF2Gts4z3thsD57q64uGp_-c,628
33
- nonebot_plugin_werewolf-1.1.12.dist-info/licenses/LICENSE,sha256=B_WbEqjGr6GYVNfEJPY31T1Opik7OtgOkhRs4Ig3e2M,1064
34
- nonebot_plugin_werewolf-1.1.12.dist-info/METADATA,sha256=_4tEZWDYjQqwkhnlTsbQA8Aik7fb1nUjpMxBMPMJ3Zs,14787
35
- nonebot_plugin_werewolf-1.1.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
36
- nonebot_plugin_werewolf-1.1.12.dist-info/top_level.txt,sha256=wLTfg8sTKbH9lLT9LtU118C9cTspEBJareLsrYM52YA,24
37
- nonebot_plugin_werewolf-1.1.12.dist-info/RECORD,,
33
+ nonebot_plugin_werewolf-1.1.13.dist-info/licenses/LICENSE,sha256=B_WbEqjGr6GYVNfEJPY31T1Opik7OtgOkhRs4Ig3e2M,1064
34
+ nonebot_plugin_werewolf-1.1.13.dist-info/METADATA,sha256=1Fx9NCJroEmg3yGPSgm56Omb2VFjsYYpR8ps41C6lN8,15344
35
+ nonebot_plugin_werewolf-1.1.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
36
+ nonebot_plugin_werewolf-1.1.13.dist-info/top_level.txt,sha256=wLTfg8sTKbH9lLT9LtU118C9cTspEBJareLsrYM52YA,24
37
+ nonebot_plugin_werewolf-1.1.13.dist-info/RECORD,,