Skip to content

Commit

Permalink
🐛 version 0.37.1
Browse files Browse the repository at this point in the history
fix use_command_start
  • Loading branch information
RF-Tar-Railt committed Feb 22, 2024
1 parent 563c772 commit 7c0a577
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 21 deletions.
3 changes: 2 additions & 1 deletion example/.env.prod
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ PORT=9555
ALCONNA_AUTO_SEND_OUTPUT=true
ALCONNA_USE_COMMAND_START=false
RED_AUTO_DETECT=true
LOG_LEVEL=DEBUG
LOG_LEVEL=DEBUG
COMMAND_START=["/", ""]
15 changes: 9 additions & 6 deletions example/plugins/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ class PipResult(Duplication):

# auto_send already set in .env
pipcmd = on_alconna(pip, comp_config={"timeout": 10}, block=True) # , auto_send_output=True)
ali = on_alconna(
Alconna(["/"], "一言"),
aliases={"hitokoto"},
skip_for_unmatch=True,
use_origin=True,
)
i18n = on_alconna(Alconna("lang", Args["lang", ["zh_CN", "en_US"]]))
login = on_alconna(
Alconna(
Expand Down Expand Up @@ -140,6 +134,15 @@ async def pip_m():
await pipcmd.send("WIP...")


ali = on_alconna(
Alconna("一言"),
aliases={"hitokoto"},
skip_for_unmatch=True,
use_cmd_start=True,
use_origin=True,
)


@ali.handle()
async def yiyan(res: Arparma):
if res.matched:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = [
{name = "RF-Tar-Railt", email = "[email protected]"},
]
dependencies = [
"arclet-alconna>=1.7.43",
"arclet-alconna>=1.7.44",
"arclet-alconna-tools>=0.6.11",
"nepattern>=0.5.15",
"nonebot2>=2.2.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 @@ -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.37.0"
__version__ = "0.37.1"

__plugin_meta__ = PluginMetadata(
name="Alconna 插件",
Expand Down
9 changes: 1 addition & 8 deletions src/nonebot_plugin_alconna/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,14 +893,6 @@ def on_alconna(
"""
if isinstance(command, str):
command = AlconnaFormat(command)
if aliases:
aliases = set(aliases)
command_manager.delete(command)
if command.command:
aliases.add(str(command.command))
command.command = "re:(" + "|".join(aliases) + ")"
command._hash = command._calc_hash()
command_manager.register(command)
_rule = alconna(
command,
skip_for_unmatch,
Expand All @@ -911,6 +903,7 @@ def on_alconna(
use_origin,
use_cmd_start,
use_cmd_sep,
aliases,
)
executor = cast(ExtensionExecutor, list(_rule.checkers)[0].call.executor) # type: ignore
params = (
Expand Down
10 changes: 7 additions & 3 deletions src/nonebot_plugin_alconna/rule.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import asyncio
import importlib
from typing import Dict, List, Type, Union, Literal, Optional, cast
from typing import Set, Dict, List, Type, Tuple, Union, Literal, Optional, cast

from nonebot import get_driver
from nonebot.typing import T_State
from tarina import lang, init_spec
from nonebot.matcher import Matcher
Expand All @@ -11,6 +10,7 @@
from nonebot.plugin.on import on_message
from nonebot.internal.rule import Rule as Rule
from nonebot.adapters import Bot, Event, Message
from nonebot import get_driver, get_plugin_config
from arclet.alconna.exceptions import SpecialOptionTriggered
from arclet.alconna import Alconna, Arparma, CompSession, output_manager, command_manager

Expand Down Expand Up @@ -63,12 +63,13 @@ def __init__(
use_origin: bool = False,
use_cmd_start: bool = False,
use_cmd_sep: bool = False,
_aliases: Optional[Union[Set[str], Tuple[str, ...]]] = None,
):
self.comp_config = comp_config
self.use_origin = use_origin
try:
global_config = get_driver().config
config = Config.parse_obj(global_config)
config = get_plugin_config(Config)
self.auto_send = auto_send_output or config.alconna_auto_send_output
if (
not command.prefixes
Expand All @@ -88,6 +89,9 @@ def __init__(
except ValueError:
self.auto_send = auto_send_output
self.command = command
if _aliases:
for alias in _aliases:
command.shortcut(alias, prefix=True)
self.skip = skip_for_unmatch
self.executor = ExtensionExecutor(self, extensions, exclude_ext)
self.executor.post_init()
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.37.0"
__version__ = "0.37.1"

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

0 comments on commit 7c0a577

Please sign in to comment.