Skip to content

Commit

Permalink
🐛 version 0.36.2
Browse files Browse the repository at this point in the history
fix action send
  • Loading branch information
RF-Tar-Railt committed Feb 1, 2024
1 parent eb7c0d0 commit e4b95ee
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/nonebot_plugin_alconna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
from .consts import ALCONNA_EXEC_RESULT as ALCONNA_EXEC_RESULT
from .extension import add_global_extension as add_global_extension

__version__ = "0.36.1"
__version__ = "0.36.2"

__plugin_meta__ = PluginMetadata(
name="Alconna 插件",
Expand Down
20 changes: 17 additions & 3 deletions src/nonebot_plugin_alconna/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
TypeVar,
Callable,
ClassVar,
Hashable,
Iterable,
NoReturn,
Protocol,
Expand Down Expand Up @@ -1055,9 +1056,9 @@ def wrapper(func: Callable[..., MReturn]) -> type[AlconnaMatcher]:
)

@matcher.handle()
async def handle(results: AlcExecResult):
async def handle_func(results: AlcExecResult):
if res := results.get(func.__name__):
if is_awaitable(res):
if isinstance(res, Hashable) and is_awaitable(res):
res = await res
if isinstance(res, (str, Message, MessageSegment, Segment, UniMessage, UniMessageTemplate)):
await matcher.send(res, fallback=True)
Expand Down Expand Up @@ -1095,7 +1096,20 @@ def build(
params.pop("self")
params.pop("__class__")
alc = super().build()
return on_alconna(alc, **params)
matcher = on_alconna(alc, **params)
if self.actions:

@matcher.handle()
async def handle_actions(results: AlcExecResult):
for res in results.values():
if isinstance(res, Hashable) and is_awaitable(res):
res = await res
if isinstance(
res, (str, Message, MessageSegment, Segment, UniMessage, UniMessageTemplate)
):
await matcher.send(res, fallback=True)

return matcher


@run_postprocessor
Expand Down
11 changes: 2 additions & 9 deletions src/nonebot_plugin_alconna/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

from nonebot import get_driver
from nonebot.typing import T_State
from tarina import lang, init_spec
from nonebot.matcher import Matcher
from nonebot.utils import escape_tag
from nonebot.params import EventMessage
from nonebot.plugin.on import on_message
from nonebot.internal.rule import Rule as Rule
from nonebot.adapters import Bot, Event, Message
from tarina import lang, init_spec, is_awaitable
from arclet.alconna.exceptions import SpecialOptionTriggered
from arclet.alconna import Alconna, Arparma, CompSession, output_manager, command_manager

Expand Down Expand Up @@ -295,14 +295,7 @@ async def __call__(self, event: Event, state: T_State, bot: Bot) -> bool:
return False
await self.executor.parse_wrapper(bot, state, event, arp)
state[ALCONNA_RESULT] = CommandResult(self.command, arp, may_help_text)
exec_result = self.command.exec_result
for key, value in exec_result.items():
if is_awaitable(value):
value = await value
if isinstance(value, (str, Message)):
value = await bot.send(event, value)
exec_result[key] = value
state[ALCONNA_EXEC_RESULT] = exec_result
state[ALCONNA_EXEC_RESULT] = self.command.exec_result
state[ALCONNA_EXTENSION] = self.executor.context
return True

Expand Down
2 changes: 1 addition & 1 deletion src/nonebot_plugin_alconna/uniseg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from .params import UniversalMessage as UniversalMessage
from .params import UniversalSegment as UniversalSegment

__version__ = "0.36.1"
__version__ = "0.36.2"

__plugin_meta__ = PluginMetadata(
name="Universal Segment 插件",
Expand Down

0 comments on commit e4b95ee

Please sign in to comment.