mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-24 09:05:04 +08:00
🐛 fix error inherit state in session when using state_factory
This commit is contained in:
parent
830276d110
commit
b2f5f93603
@ -575,13 +575,13 @@ class Matcher(metaclass=MatcherMeta):
|
|||||||
e_t = current_event.set(event)
|
e_t = current_event.set(event)
|
||||||
try:
|
try:
|
||||||
# Refresh preprocess state
|
# Refresh preprocess state
|
||||||
state_ = await self._default_state_factory(
|
self.state = await self._default_state_factory(
|
||||||
bot, event) if self._default_state_factory else self.state
|
bot, event) if self._default_state_factory else self.state
|
||||||
state_.update(state)
|
self.state.update(state)
|
||||||
|
|
||||||
for _ in range(len(self.handlers)):
|
for _ in range(len(self.handlers)):
|
||||||
handler = self.handlers.pop(0)
|
handler = self.handlers.pop(0)
|
||||||
await handler(self, bot, event, state_)
|
await handler(self, bot, event, self.state)
|
||||||
|
|
||||||
except RejectedException:
|
except RejectedException:
|
||||||
self.handlers.insert(0, handler) # type: ignore
|
self.handlers.insert(0, handler) # type: ignore
|
||||||
@ -590,7 +590,7 @@ class Matcher(metaclass=MatcherMeta):
|
|||||||
type_ = await updater(
|
type_ = await updater(
|
||||||
bot,
|
bot,
|
||||||
event,
|
event,
|
||||||
state_, # type: ignore
|
self.state, # type: ignore
|
||||||
self.type)
|
self.type)
|
||||||
else:
|
else:
|
||||||
type_ = "message"
|
type_ = "message"
|
||||||
@ -600,7 +600,7 @@ class Matcher(metaclass=MatcherMeta):
|
|||||||
permission = await updater(
|
permission = await updater(
|
||||||
bot,
|
bot,
|
||||||
event,
|
event,
|
||||||
state_, # type: ignore
|
self.state, # type: ignore
|
||||||
self.permission)
|
self.permission)
|
||||||
else:
|
else:
|
||||||
permission = USER(event.get_session_id(), perm=self.permission)
|
permission = USER(event.get_session_id(), perm=self.permission)
|
||||||
@ -626,7 +626,7 @@ class Matcher(metaclass=MatcherMeta):
|
|||||||
type_ = await updater(
|
type_ = await updater(
|
||||||
bot,
|
bot,
|
||||||
event,
|
event,
|
||||||
state_, # type: ignore
|
self.state, # type: ignore
|
||||||
self.type)
|
self.type)
|
||||||
else:
|
else:
|
||||||
type_ = "message"
|
type_ = "message"
|
||||||
@ -636,7 +636,7 @@ class Matcher(metaclass=MatcherMeta):
|
|||||||
permission = await updater(
|
permission = await updater(
|
||||||
bot,
|
bot,
|
||||||
event,
|
event,
|
||||||
state_, # type: ignore
|
self.state, # type: ignore
|
||||||
self.permission)
|
self.permission)
|
||||||
else:
|
else:
|
||||||
permission = USER(event.get_session_id(), perm=self.permission)
|
permission = USER(event.get_session_id(), perm=self.permission)
|
||||||
|
@ -13,6 +13,7 @@ sidebar: auto
|
|||||||
- 移除 `bot.call_api` 参数 `self_id` 切换机器人支持
|
- 移除 `bot.call_api` 参数 `self_id` 切换机器人支持
|
||||||
- 修复 `type_updater` `permission_updater` 未传递的错误
|
- 修复 `type_updater` `permission_updater` 未传递的错误
|
||||||
- 修复 `type_updater` `permission_updater` 参数 `state` 错误
|
- 修复 `type_updater` `permission_updater` 参数 `state` 错误
|
||||||
|
- 修复使用 `state_factory` 后导致无法在 session 内传递 `state`
|
||||||
|
|
||||||
## v2.0.0a13.post1
|
## v2.0.0a13.post1
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user