nonebot-plugin-werewolf 1.1.1__py3-none-any.whl → 1.1.3__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.
Files changed (32) hide show
  1. nonebot_plugin_werewolf/__init__.py +8 -4
  2. nonebot_plugin_werewolf/_timeout.py +110 -0
  3. nonebot_plugin_werewolf/config.py +15 -18
  4. nonebot_plugin_werewolf/constant.py +18 -3
  5. nonebot_plugin_werewolf/exception.py +1 -1
  6. nonebot_plugin_werewolf/game.py +91 -110
  7. nonebot_plugin_werewolf/matchers/__init__.py +2 -0
  8. nonebot_plugin_werewolf/matchers/message_in_game.py +15 -0
  9. nonebot_plugin_werewolf/{ob11_ext.py → matchers/ob11_ext.py} +26 -20
  10. nonebot_plugin_werewolf/matchers/start_game.py +56 -0
  11. nonebot_plugin_werewolf/player_set.py +9 -7
  12. nonebot_plugin_werewolf/players/__init__.py +10 -0
  13. nonebot_plugin_werewolf/players/can_shoot.py +59 -0
  14. nonebot_plugin_werewolf/players/civilian.py +7 -0
  15. nonebot_plugin_werewolf/players/guard.py +37 -0
  16. nonebot_plugin_werewolf/players/hunter.py +8 -0
  17. nonebot_plugin_werewolf/players/idiot.py +44 -0
  18. nonebot_plugin_werewolf/players/joker.py +21 -0
  19. nonebot_plugin_werewolf/players/player.py +161 -0
  20. nonebot_plugin_werewolf/players/prophet.py +30 -0
  21. nonebot_plugin_werewolf/players/werewolf.py +67 -0
  22. nonebot_plugin_werewolf/players/witch.py +72 -0
  23. nonebot_plugin_werewolf/players/wolfking.py +14 -0
  24. nonebot_plugin_werewolf/utils.py +83 -65
  25. {nonebot_plugin_werewolf-1.1.1.dist-info → nonebot_plugin_werewolf-1.1.3.dist-info}/METADATA +20 -8
  26. nonebot_plugin_werewolf-1.1.3.dist-info/RECORD +29 -0
  27. {nonebot_plugin_werewolf-1.1.1.dist-info → nonebot_plugin_werewolf-1.1.3.dist-info}/WHEEL +1 -1
  28. nonebot_plugin_werewolf/matchers.py +0 -63
  29. nonebot_plugin_werewolf/player.py +0 -455
  30. nonebot_plugin_werewolf-1.1.1.dist-info/RECORD +0 -15
  31. {nonebot_plugin_werewolf-1.1.1.dist-info → nonebot_plugin_werewolf-1.1.3.dist-info}/LICENSE +0 -0
  32. {nonebot_plugin_werewolf-1.1.1.dist-info → nonebot_plugin_werewolf-1.1.3.dist-info}/top_level.txt +0 -0
@@ -1,15 +1,16 @@
1
1
  import asyncio
2
- import asyncio.timeouts
2
+ import itertools
3
3
  import re
4
4
  from collections import defaultdict
5
- from typing import Annotated, Any, ClassVar
5
+ from typing import Any, ClassVar
6
6
 
7
+ import nonebot
7
8
  import nonebot_plugin_waiter as waiter
8
- from nonebot.adapters import Event
9
- from nonebot.log import logger
9
+ from nonebot.adapters import Bot, Event
10
10
  from nonebot.rule import to_me
11
- from nonebot_plugin_alconna import MsgTarget, UniMessage, UniMsg
12
- from nonebot_plugin_userinfo import EventUserInfo, UserInfo
11
+ from nonebot.utils import escape_tag
12
+ from nonebot_plugin_alconna import MsgTarget, Target, UniMessage, UniMsg
13
+ from nonebot_plugin_uninfo import Uninfo
13
14
 
14
15
  from .config import config
15
16
 
@@ -25,49 +26,66 @@ def check_index(text: str, arrlen: int) -> int | None:
25
26
  class InputStore:
26
27
  locks: ClassVar[dict[str, asyncio.Lock]] = defaultdict(asyncio.Lock)
27
28
  futures: ClassVar[dict[str, asyncio.Future[UniMessage]]] = {}
29
+ clear_handle: ClassVar[dict[str, asyncio.Handle]] = {}
30
+
31
+ @classmethod
32
+ def clear_lock(cls, key: str) -> None:
33
+ if key in cls.locks and not cls.locks[key].locked():
34
+ del cls.locks[key]
35
+ if key in cls.clear_handle:
36
+ del cls.clear_handle[key]
28
37
 
29
38
  @classmethod
30
39
  async def fetch(cls, user_id: str, group_id: str | None = None) -> UniMessage[Any]:
31
40
  key = f"{group_id}_{user_id}"
32
41
  async with cls.locks[key]:
33
- cls.futures[key] = asyncio.get_event_loop().create_future()
42
+ cls.futures[key] = fut = asyncio.get_event_loop().create_future()
34
43
  try:
35
- return await cls.futures[key]
44
+ return await fut
36
45
  finally:
37
46
  del cls.futures[key]
47
+ if key in cls.clear_handle:
48
+ cls.clear_handle[key].cancel()
49
+ loop = asyncio.get_event_loop()
50
+ cls.clear_handle[key] = loop.call_later(120, cls.clear_lock, key)
38
51
 
39
52
  @classmethod
40
- def put(cls, user_id: str, group_id: str | None, msg: UniMessage) -> None:
53
+ def put(cls, msg: UniMessage, user_id: str, group_id: str | None = None) -> None:
41
54
  key = f"{group_id}_{user_id}"
42
- if future := cls.futures.get(key):
55
+ if (future := cls.futures.get(key)) and not future.cancelled():
43
56
  future.set_result(msg)
44
57
 
45
58
 
46
- def user_in_game(user_id: str, group_id: str | None) -> bool:
47
- from .game import running_games
59
+ def user_in_game(self_id: str, user_id: str, group_id: str | None) -> bool:
60
+ from .game import Game
48
61
 
49
- if group_id is not None and group_id not in running_games:
50
- return False
51
- games = running_games.values() if group_id is None else [running_games[group_id]]
52
- for game in games:
62
+ if group_id is None:
63
+ return any(
64
+ self_id == p.user.self_id and user_id == p.user_id
65
+ for p in itertools.chain(*[g.players for g in Game.running_games])
66
+ )
67
+
68
+ def check(game: Game) -> bool:
69
+ return self_id == game.group.self_id and group_id == game.group.id
70
+
71
+ if game := next(filter(check, Game.running_games), None):
53
72
  return any(user_id == player.user_id for player in game.players)
73
+
54
74
  return False
55
75
 
56
76
 
57
- async def rule_in_game(event: Event, target: MsgTarget) -> bool:
58
- from .game import running_games
77
+ async def rule_in_game(bot: Bot, event: Event, target: MsgTarget) -> bool:
78
+ from .game import Game
59
79
 
60
- if not running_games:
80
+ if not Game.running_games:
61
81
  return False
62
82
  if target.private:
63
- return user_in_game(target.id, None)
64
- if target.id in running_games:
65
- return user_in_game(event.get_user_id(), target.id)
66
- return False
83
+ return user_in_game(bot.self_id, target.id, None)
84
+ return user_in_game(bot.self_id, event.get_user_id(), target.id)
67
85
 
68
86
 
69
- async def rule_not_in_game(event: Event, target: MsgTarget) -> bool:
70
- return not await rule_in_game(event, target)
87
+ async def rule_not_in_game(bot: Bot, event: Event, target: MsgTarget) -> bool:
88
+ return not await rule_in_game(bot, event, target)
71
89
 
72
90
 
73
91
  async def is_group(target: MsgTarget) -> bool:
@@ -77,35 +95,35 @@ async def is_group(target: MsgTarget) -> bool:
77
95
  async def _prepare_game_receive(
78
96
  queue: asyncio.Queue[tuple[str, str, str]],
79
97
  event: Event,
80
- group_id: str,
98
+ group: Target,
81
99
  ) -> None:
82
- async def rule(target_: MsgTarget) -> bool:
83
- return not target_.private and target_.id == group_id
100
+ async def same_group(target: MsgTarget) -> bool:
101
+ return group.verify(target)
84
102
 
85
103
  @waiter.waiter(
86
104
  waits=[event.get_type()],
87
105
  keep_session=False,
88
- rule=to_me() & rule & rule_not_in_game,
106
+ rule=to_me() & same_group & rule_not_in_game,
89
107
  )
90
108
  def wait(
91
109
  event: Event,
92
- info: Annotated[UserInfo | None, EventUserInfo()],
93
110
  msg: UniMsg,
111
+ session: Uninfo,
94
112
  ) -> tuple[str, str, str]:
113
+ user_id = event.get_user_id()
114
+ name = session.user.nick or session.user.name or user_id
115
+ if session.member:
116
+ name = session.member.nick or name
95
117
  return (
96
- event.get_user_id(),
97
- (
98
- (info.user_displayname or info.user_name)
99
- if info is not None
100
- else event.get_user_id()
101
- ),
118
+ user_id,
102
119
  msg.extract_plain_text().strip(),
120
+ name,
103
121
  )
104
122
 
105
- async for user, name, text in wait(default=(None, "", "")):
123
+ async for user, text, name in wait(default=(None, "", "")):
106
124
  if user is None:
107
125
  continue
108
- await queue.put((user, re.sub(r"[\u2066-\u2069]", "", name), text))
126
+ await queue.put((user, text, re.sub(r"[\u2066-\u2069]", "", name)))
109
127
 
110
128
 
111
129
  async def _prepare_game_handle(
@@ -113,12 +131,12 @@ async def _prepare_game_handle(
113
131
  players: dict[str, str],
114
132
  admin_id: str,
115
133
  ) -> None:
116
- log = logger.opt(colors=True)
134
+ logger = nonebot.logger.opt(colors=True)
117
135
 
118
136
  while True:
119
- user, name, text = await queue.get()
120
- msg = UniMessage.at(user)
121
- colored = f"<y>{name}</y>(<c>{user}</c>)"
137
+ user, text, name = await queue.get()
138
+ msg = UniMessage.at(user).text("\n")
139
+ colored = f"<y>{escape_tag(name)}</y>(<c>{escape_tag(user)}</c>)"
122
140
 
123
141
  match (text, user == admin_id):
124
142
  case ("开始游戏", True):
@@ -126,77 +144,77 @@ async def _prepare_game_handle(
126
144
  role_preset = config.get_role_preset()
127
145
  if player_num < min(role_preset):
128
146
  await (
129
- msg.text(f"游戏至少需要 {min(role_preset)} 人, ")
147
+ msg.text(f"⚠️游戏至少需要 {min(role_preset)} 人, ")
130
148
  .text(f"当前已有 {player_num} 人")
131
149
  .send()
132
150
  )
133
151
  elif player_num > max(role_preset):
134
152
  await (
135
- msg.text(f"游戏最多需要 {max(role_preset)} 人, ")
153
+ msg.text(f"⚠️游戏最多需要 {max(role_preset)} 人, ")
136
154
  .text(f"当前已有 {player_num} 人")
137
155
  .send()
138
156
  )
139
157
  elif player_num not in role_preset:
140
158
  await (
141
- msg.text(f"不存在总人数为 {player_num} 的预设, ")
159
+ msg.text(f"⚠️不存在总人数为 {player_num} 的预设, ")
142
160
  .text("无法开始游戏")
143
161
  .send()
144
162
  )
145
163
  else:
146
- await msg.text("游戏即将开始...").send()
147
- log.info(f"游戏发起者 {colored} 开始游戏")
164
+ await msg.text("✏️游戏即将开始...").send()
165
+ logger.info(f"游戏发起者 {colored} 开始游戏")
148
166
  return
149
167
 
150
168
  case ("开始游戏", False):
151
- await msg.text("只有游戏发起者可以开始游戏").send()
169
+ await msg.text("⚠️只有游戏发起者可以开始游戏").send()
152
170
 
153
171
  case ("结束游戏", True):
154
- log.info(f"游戏发起者 {colored} 结束游戏")
155
- await msg.text("已结束当前游戏").finish()
172
+ logger.info(f"游戏发起者 {colored} 结束游戏")
173
+ await msg.text("ℹ️已结束当前游戏").finish()
156
174
 
157
175
  case ("结束游戏", False):
158
- await msg.text("只有游戏发起者可以结束游戏").send()
176
+ await msg.text("⚠️只有游戏发起者可以结束游戏").send()
159
177
 
160
178
  case ("加入游戏", True):
161
- await msg.text("游戏发起者已经加入游戏了").send()
179
+ await msg.text("ℹ️游戏发起者已经加入游戏了").send()
162
180
 
163
181
  case ("加入游戏", False):
164
182
  if user not in players:
165
183
  players[user] = name
166
- log.info(f"玩家 {colored} 加入游戏")
167
- await msg.text("成功加入游戏").send()
184
+ logger.info(f"玩家 {colored} 加入游戏")
185
+ await msg.text("✅成功加入游戏").send()
168
186
  else:
169
- await msg.text("你已经加入游戏了").send()
187
+ await msg.text("ℹ️你已经加入游戏了").send()
170
188
 
171
189
  case ("退出游戏", True):
172
- await msg.text("游戏发起者无法退出游戏").send()
190
+ await msg.text("ℹ️游戏发起者无法退出游戏").send()
173
191
 
174
192
  case ("退出游戏", False):
175
193
  if user in players:
176
194
  del players[user]
177
- log.info(f"玩家 {colored} 退出游戏")
178
- await msg.text("成功退出游戏").send()
195
+ logger.info(f"玩家 {colored} 退出游戏")
196
+ await msg.text("✅成功退出游戏").send()
179
197
  else:
180
- await msg.text("你还没有加入游戏").send()
198
+ await msg.text("ℹ️你还没有加入游戏").send()
181
199
 
182
200
  case ("当前玩家", _):
183
- msg.text("\n当前玩家:\n")
201
+ msg.text("✨当前玩家:\n")
184
202
  for idx, name in enumerate(players.values(), 1):
185
203
  msg.text(f"\n{idx}. {name}")
186
204
  await msg.send()
187
205
 
188
206
 
189
207
  async def prepare_game(event: Event, players: dict[str, str]) -> None:
190
- from .game import starting_games
208
+ from .game import Game
191
209
 
192
- group_id = UniMessage.get_target(event).id
193
- starting_games[group_id] = players
210
+ group = UniMessage.get_target(event)
211
+ Game.starting_games[group] = players
194
212
 
195
213
  queue: asyncio.Queue[tuple[str, str, str]] = asyncio.Queue()
196
- task_receive = asyncio.create_task(_prepare_game_receive(queue, event, group_id))
214
+ task_receive = asyncio.create_task(_prepare_game_receive(queue, event, group))
197
215
 
198
216
  try:
199
217
  await _prepare_game_handle(queue, players, event.get_user_id())
200
218
  finally:
201
219
  task_receive.cancel()
202
- del starting_games[group_id]
220
+ del Game.starting_games[group]
@@ -1,20 +1,23 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-werewolf
3
- Version: 1.1.1
3
+ Version: 1.1.3
4
4
  Summary: 适用于 Nonebot2 的狼人杀插件
5
5
  Author-email: wyf7685 <wyf7685@163.com>
6
6
  License: MIT
7
- Requires-Python: >=3.11
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
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
14
17
 
15
18
  <div align="center">
16
19
  <a href="https://v2.nonebot.dev/store">
17
- <img src="https://github.com/wyf7685/wyf7685/blob/main/assets/NoneBotPlugin.svg" width="300" alt="logo">
20
+ <img src="https://raw.githubusercontent.com/wyf7685/wyf7685/main/assets/NoneBotPlugin.svg" width="300" alt="logo">
18
21
  </a>
19
22
  </div>
20
23
 
@@ -26,14 +29,14 @@ _✨ 简单的狼人杀插件 ✨_
26
29
 
27
30
  [![license](https://img.shields.io/github/license/wyf7685/nonebot-plugin-werewolf.svg)](./LICENSE)
28
31
  [![pypi](https://img.shields.io/pypi/v/nonebot-plugin-werewolf?logo=python&logoColor=edb641)](https://pypi.python.org/pypi/nonebot-plugin-werewolf)
29
- [![python](https://img.shields.io/badge/python-3.11+-blue?logo=python&logoColor=edb641)](https://www.python.org/)
32
+ [![python](https://img.shields.io/badge/python-3.10+-blue?logo=python&logoColor=edb641)](https://www.python.org/)
33
+
30
34
  [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
31
35
  [![ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
32
36
  [![isort](https://img.shields.io/badge/%20imports-isort-%231674b1)](https://pycqa.github.io/isort/)
33
37
  [![black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
34
38
  [![pyright](https://img.shields.io/badge/types-pyright-797952.svg?logo=python&logoColor=edb641)](https://github.com/Microsoft/pyright)
35
39
 
36
- [![commits](https://img.shields.io/github/commit-activity/w/wyf7685/nonebot-plugin-werewolf)](https://github.com/wyf7685/nonebot-plugin-werewolf/commits)
37
40
  [![wakatime](https://wakatime.com/badge/user/b097681b-c224-44ec-8e04-e1cf71744655/project/70a7f68d-5625-4989-9476-be6877408332.svg)](https://wakatime.com/badge/user/b097681b-c224-44ec-8e04-e1cf71744655/project/70a7f68d-5625-4989-9476-be6877408332)
38
41
  [![pre-commit](https://results.pre-commit.ci/badge/github/wyf7685/nonebot-plugin-werewolf/master.svg)](https://results.pre-commit.ci/latest/github/wyf7685/nonebot-plugin-werewolf/master)
39
42
  [![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)
@@ -52,7 +55,7 @@ _✨ 简单的狼人杀插件 ✨_
52
55
 
53
56
  > [!note]
54
57
  >
55
- > 请确保 NoneBot2 使用的 Python 解释器版本 >=3.11
58
+ > 请确保 NoneBot2 使用的 Python 解释器版本 >=3.10
56
59
 
57
60
  <details open>
58
61
  <summary>使用 nb-cli 安装</summary>
@@ -240,6 +243,15 @@ werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
240
243
 
241
244
  <!-- CHANGELOG -->
242
245
 
246
+ - 2024.10.06 v1.1.3
247
+
248
+ - 使用 `RF-Tar-Railt/nonebot-plugin-uninfo` 获取用户数据
249
+ - 优化交互文本
250
+
251
+ - 2024.09.18 v1.1.2
252
+
253
+ - 修改 Python 需求为 `>=3.10`
254
+
243
255
  - 2024.09.11 v1.1.1
244
256
 
245
257
  - 修改 Python 需求为 `>=3.11`
@@ -280,6 +292,6 @@ werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
280
292
 
281
293
  - [`nonebot/nonebot2`](https://github.com/nonebot/nonebot2): 跨平台 Python 异步机器人框架
282
294
  - [`nonebot/plugin-alconna`](https://github.com/nonebot/plugin-alconna): 跨平台的消息处理接口
283
- - [`noneplugin/nonebot-plugin-userinfo`](https://github.com/noneplugin/nonebot-plugin-userinfo): 用户信息获取
295
+ - [`RF-Tar-Railt/nonebot-plugin-uninfo`](https://github.com/RF-Tar-Railt/nonebot-plugin-uninfo): 用户信息获取
284
296
  - [`RF-Tar-Railt/nonebot-plugin-waiter`](https://github.com/RF-Tar-Railt/nonebot-plugin-waiter): 灵活获取用户输入
285
297
  - `热心群友`: 协助测试插件
@@ -0,0 +1,29 @@
1
+ nonebot_plugin_werewolf/__init__.py,sha256=Im_u8hP6N6qA2SwnNSGu1MsewLoyHUa3v0Paj1yC3T0,862
2
+ nonebot_plugin_werewolf/_timeout.py,sha256=MVkA5oMoxOTV8Luc0BH2QPP8wwz4Tr9CJjeYgiPu_O4,3649
3
+ nonebot_plugin_werewolf/config.py,sha256=FKQDkb57ujcBYJZX-sLgxWmTVqSeR7T1ywphp7GOCcE,2803
4
+ nonebot_plugin_werewolf/constant.py,sha256=-S-KjlrSc_wJwsXCkQOMFVqyu4RwR4GLXIRZEp_0mlI,2300
5
+ nonebot_plugin_werewolf/exception.py,sha256=YSwxeogIB0YJqH9MP1bgxojiu-I_xQE44XnSk5bC1AQ,400
6
+ nonebot_plugin_werewolf/game.py,sha256=LWxn2OCnkTAF8NdLt1BQzyAtyUfk477xisCf5mbfK_E,17376
7
+ nonebot_plugin_werewolf/player_set.py,sha256=BlK7wHv_9YrCINMAPWL36TLkRjAiI_GXSHlZySVemoo,2777
8
+ nonebot_plugin_werewolf/utils.py,sha256=50bJGhJU7b9kQEqmc2V8-5wYkukilDtchZBSBKcwwq4,7633
9
+ nonebot_plugin_werewolf/matchers/__init__.py,sha256=_MwAZsXlpBLXyzHWqNLTQdMWw9z_O01L5Yo02dzGC9I,88
10
+ nonebot_plugin_werewolf/matchers/message_in_game.py,sha256=hpQCaNaxCikma8DJTJLCttP5B1vBWlqMDEukSqfPlRk,452
11
+ nonebot_plugin_werewolf/matchers/ob11_ext.py,sha256=TGhI4yWfb5N3K9hXkI8k8Rs6cMVXDwp05cXtu3a-_jU,2597
12
+ nonebot_plugin_werewolf/matchers/start_game.py,sha256=DZPQ88hiobuJejIbKsIc8ZcoKDw7wcjawWfTC3wjIto,1884
13
+ nonebot_plugin_werewolf/players/__init__.py,sha256=djAI5XxR2I-XvnH-lVqX_YCHB_AiT-6jdmwFE1ffN_0,379
14
+ nonebot_plugin_werewolf/players/can_shoot.py,sha256=6u_luXfNOWO0svTpb78h74HcG65kh1GZyFPJFYNuOG0,2068
15
+ nonebot_plugin_werewolf/players/civilian.py,sha256=6iKEWRRWDGq1qgVZZZ9pX7kBVpMN-yfxeLq9hIp17hU,165
16
+ nonebot_plugin_werewolf/players/guard.py,sha256=pDH66q-KoU5oRD-tn542x3siXv9BM824-KRxsVb0Gvk,1408
17
+ nonebot_plugin_werewolf/players/hunter.py,sha256=nqYGCVppd4mdCPhFHZbjbbNvZfyCNT0bZ3raQFXmELA,203
18
+ nonebot_plugin_werewolf/players/idiot.py,sha256=7-BTsYUSOcs5rPOJx1hsHPOWcmGcv2rSO8IfUGPdqEE,1456
19
+ nonebot_plugin_werewolf/players/joker.py,sha256=uUK6EuoOWd8_35yvBTkM14XCplOFwFCRsbhR7bjeiD8,699
20
+ nonebot_plugin_werewolf/players/player.py,sha256=ejEjbsrIKpUJql3-qLMFsZY_jGFtQ3OTjcN1lFZ4yKo,4697
21
+ nonebot_plugin_werewolf/players/prophet.py,sha256=nh8eB9T9LMBiqNgnqE-ygAFiYvTZS8bGUKYsNBPm8F0,1078
22
+ nonebot_plugin_werewolf/players/werewolf.py,sha256=kyZjwijEGG0EkP80VOlu8HFzReg33v8a-o670fZN_xI,2560
23
+ nonebot_plugin_werewolf/players/witch.py,sha256=P1odgjFc9kAIUxmlz9aV69aYzl76OVcsQQGhigmRTgc,2571
24
+ nonebot_plugin_werewolf/players/wolfking.py,sha256=hgxOugrIOF6wC5wKcjflPuQ2K4d99eWpF9E69ishbsg,440
25
+ nonebot_plugin_werewolf-1.1.3.dist-info/LICENSE,sha256=B_WbEqjGr6GYVNfEJPY31T1Opik7OtgOkhRs4Ig3e2M,1064
26
+ nonebot_plugin_werewolf-1.1.3.dist-info/METADATA,sha256=uLZxheMxeLRL70cOrpZtr1Nqy2gP1sAIFNiiNtkEwi4,10707
27
+ nonebot_plugin_werewolf-1.1.3.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
28
+ nonebot_plugin_werewolf-1.1.3.dist-info/top_level.txt,sha256=wLTfg8sTKbH9lLT9LtU118C9cTspEBJareLsrYM52YA,24
29
+ nonebot_plugin_werewolf-1.1.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (74.1.2)
2
+ Generator: setuptools (75.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,63 +0,0 @@
1
- import asyncio
2
- import asyncio.timeouts
3
- from typing import Annotated
4
-
5
- from nonebot import on_command, on_message
6
- from nonebot.adapters import Bot, Event
7
- from nonebot.exception import FinishedException
8
- from nonebot.rule import to_me
9
- from nonebot_plugin_alconna import MsgTarget, UniMessage, UniMsg
10
- from nonebot_plugin_userinfo import EventUserInfo, UserInfo
11
-
12
- from .game import Game
13
- from .ob11_ext import ob11_ext_enabled
14
- from .utils import InputStore, is_group, prepare_game, rule_in_game, rule_not_in_game
15
-
16
- in_game_message = on_message(rule=rule_in_game)
17
- start_game = on_command(
18
- "werewolf",
19
- rule=to_me() & is_group & rule_not_in_game,
20
- aliases={"狼人杀"},
21
- )
22
-
23
-
24
- @in_game_message.handle()
25
- async def handle_input(event: Event, target: MsgTarget, msg: UniMsg) -> None:
26
- if target.private:
27
- InputStore.put(target.id, None, msg)
28
- else:
29
- InputStore.put(event.get_user_id(), target.id, msg)
30
-
31
-
32
- @start_game.handle()
33
- async def handle_start(
34
- bot: Bot,
35
- event: Event,
36
- target: MsgTarget,
37
- admin_info: Annotated[UserInfo, EventUserInfo()],
38
- ) -> None:
39
- admin_id = event.get_user_id()
40
- msg = (
41
- UniMessage.at(admin_id)
42
- .text("成功创建游戏\n")
43
- .text("玩家请 @我 发送 “加入游戏”、“退出游戏”\n")
44
- .text("玩家 @我 发送 “当前玩家” 可查看玩家列表\n")
45
- .text("游戏发起者 @我 发送 “结束游戏” 可结束当前游戏\n")
46
- .text("玩家均加入后,游戏发起者请 @我 发送 “开始游戏”\n")
47
- )
48
- if ob11_ext_enabled():
49
- msg.text("\n可使用戳一戳代替游戏交互中的 “/stop” 命令")
50
- await msg.text("\n\n游戏准备阶段限时5分钟,超时将自动结束").send()
51
-
52
- players = {admin_id: admin_info.user_name}
53
-
54
- try:
55
- async with asyncio.timeouts.timeout(5 * 60):
56
- await prepare_game(event, players)
57
- except FinishedException:
58
- raise
59
- except TimeoutError:
60
- await UniMessage.text("游戏准备超时,已自动结束").finish()
61
-
62
- game = Game(bot, target, players)
63
- game.start()