Skip to content

Commit

Permalink
🐛 version 0.50.3
Browse files Browse the repository at this point in the history
fix `CommandResult.source`
  • Loading branch information
RF-Tar-Railt committed Aug 4, 2024
1 parent baa6141 commit 550657c
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 228 deletions.
289 changes: 74 additions & 215 deletions pdm.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ authors = [
dependencies = [
"tarina>=0.5.4",
"nepattern>=0.7.4",
"arclet-alconna>=1.8.19",
"arclet-alconna-tools>=0.7.6",
"arclet-alconna>=1.8.21",
"arclet-alconna-tools>=0.7.8",
"importlib-metadata>=4.13.0",
"nonebot2>=2.3.0",
"nonebot-plugin-waiter>=0.6.0",
Expand Down
2 changes: 1 addition & 1 deletion src/nonebot_plugin_alconna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
from .uniseg import SupportAdapterModule as SupportAdapterModule
from .extension import add_global_extension as add_global_extension

__version__ = "0.50.2"
__version__ = "0.50.3"

__plugin_meta__ = PluginMetadata(
name="Alconna 插件",
Expand Down
4 changes: 0 additions & 4 deletions src/nonebot_plugin_alconna/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,10 +1101,6 @@ class Command(AlconnaString):
def args_gen(pattern: str, types: dict):
return AlconnaString.args_gen(pattern, {**types, **patterns})

def namespace(self, ns: str | Namespace):
self.buffer["namespace"] = ns
return self

def build(
self,
rule: Rule | T_RuleChecker | None = None,
Expand Down
3 changes: 1 addition & 2 deletions src/nonebot_plugin_alconna/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ def __repr__(self):


class CommandResult(BaseModel):
_source: ReferenceType[Alconna]
result: Arparma
output: Optional[str] = Field(default=None)

@property
def source(self) -> Alconna:
return self._source() # type: ignore
return self.result.source

@property
def matched(self) -> bool:
Expand Down
6 changes: 3 additions & 3 deletions src/nonebot_plugin_alconna/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def _checker(_event: Event):

self._matchers[session_id] = on_message(priority=0, block=True, rule=Rule(_checker), handlers=[self._waiter])
res = Arparma(
self._path,
cmd._hash,
msg,
False,
error_info=SpecialOptionTriggered("completion"),
Expand Down Expand Up @@ -284,7 +284,7 @@ async def __call__(self, event: Event, state: T_State, bot: Bot) -> bool:
self.executor.clear()
return False
except Exception as e:
arp = Arparma(self._path, msg, False, error_info=e)
arp = Arparma(cmd._hash, msg, False, error_info=e)
may_help_text: Optional[str] = cap.get("output", None)
if not arp.head_matched:
self.executor.clear()
Expand All @@ -311,7 +311,7 @@ async def __call__(self, event: Event, state: T_State, bot: Bot) -> bool:
self.executor.clear()
return False
await self.executor.parse_wrapper(bot, state, event, arp)
state[ALCONNA_RESULT] = CommandResult(_source=self.command, result=arp, output=may_help_text)
state[ALCONNA_RESULT] = CommandResult(result=arp, output=may_help_text)
state[ALCONNA_EXEC_RESULT] = cmd.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 @@ -53,7 +53,7 @@
from .constraint import SupportAdapterModule as SupportAdapterModule
from .adapters import BUILDER_MAPPING, FETCHER_MAPPING, EXPORTER_MAPPING

__version__ = "0.50.2"
__version__ = "0.50.3"

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

0 comments on commit 550657c

Please sign in to comment.