Skip to content

Commit 17df169

Browse files
committed
fix: 修复 /alter_cmd reset scene <num> xxx 不可用的问题
1 parent 9ab6526 commit 17df169

3 files changed

Lines changed: 33 additions & 48 deletions

File tree

packages/astrbot/commands/alter_cmd.py

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,7 @@
66
from astrbot.core.star.filter.command import CommandFilter
77
from astrbot.core.star.filter.command_group import CommandGroupFilter
88
from astrbot.core.star.filter.permission import PermissionTypeFilter
9-
from enum import Enum
10-
11-
12-
class RstScene(Enum):
13-
GROUP_UNIQUE_ON = ("group_unique_on", "群聊+会话隔离开启")
14-
GROUP_UNIQUE_OFF = ("group_unique_off", "群聊+会话隔离关闭")
15-
PRIVATE = ("private", "私聊")
16-
17-
@property
18-
def key(self) -> str:
19-
return self.value[0]
20-
21-
@property
22-
def name(self) -> str:
23-
return self.value[1]
24-
25-
@classmethod
26-
def from_index(cls, index: int) -> "RstScene":
27-
mapping = {1: cls.GROUP_UNIQUE_ON, 2: cls.GROUP_UNIQUE_OFF, 3: cls.PRIVATE}
28-
return mapping[index]
9+
from .utils.rst_scene import RstScene
2910

3011

3112
class AlterCmdCommands(CommandParserMixin):
@@ -58,8 +39,9 @@ async def alter_cmd(self, event: AstrMessageEvent):
5839
)
5940
return
6041

61-
cmd_name = " ".join(token.tokens[1:-1])
62-
cmd_type = token.get(-1)
42+
# 兼容 reset scene 的专门配置
43+
cmd_name = token.get(1)
44+
cmd_type = token.get(2)
6345

6446
if cmd_name == "reset" and cmd_type == "config":
6547
from astrbot.api import sp
@@ -123,6 +105,8 @@ async def alter_cmd(self, event: AstrMessageEvent):
123105
return
124106

125107
# 查找指令
108+
cmd_name = " ".join(token.tokens[1:-1])
109+
cmd_type = token.get(-1)
126110
found_command = None
127111
cmd_group = False
128112
for handler in star_handlers_registry:

packages/astrbot/commands/conversation.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,8 @@
77
from astrbot.core.provider.sources.coze_source import ProviderCoze
88
from astrbot.api import sp, logger
99
from ..long_term_memory import LongTermMemory
10+
from .utils.rst_scene import RstScene
1011
from typing import Union
11-
from enum import Enum
12-
13-
14-
class RstScene(Enum):
15-
GROUP_UNIQUE_ON = ("group_unique_on", "群聊+会话隔离开启")
16-
GROUP_UNIQUE_OFF = ("group_unique_off", "群聊+会话隔离关闭")
17-
PRIVATE = ("private", "私聊")
18-
19-
@property
20-
def key(self) -> str:
21-
return self.value[0]
22-
23-
@property
24-
def name(self) -> str:
25-
return self.value[1]
26-
27-
@classmethod
28-
def from_index(cls, index: int) -> "RstScene":
29-
mapping = {1: cls.GROUP_UNIQUE_ON, 2: cls.GROUP_UNIQUE_OFF, 3: cls.PRIVATE}
30-
return mapping[index]
31-
32-
@classmethod
33-
def get_scene(cls, is_group: bool, is_unique_session: bool) -> "RstScene":
34-
if is_group:
35-
return cls.GROUP_UNIQUE_ON if is_unique_session else cls.GROUP_UNIQUE_OFF
36-
return cls.PRIVATE
3712

3813

3914
class ConversationCommands:
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from enum import Enum
2+
3+
4+
class RstScene(Enum):
5+
GROUP_UNIQUE_ON = ("group_unique_on", "群聊+会话隔离开启")
6+
GROUP_UNIQUE_OFF = ("group_unique_off", "群聊+会话隔离关闭")
7+
PRIVATE = ("private", "私聊")
8+
9+
@property
10+
def key(self) -> str:
11+
return self.value[0]
12+
13+
@property
14+
def name(self) -> str:
15+
return self.value[1]
16+
17+
@classmethod
18+
def from_index(cls, index: int) -> "RstScene":
19+
mapping = {1: cls.GROUP_UNIQUE_ON, 2: cls.GROUP_UNIQUE_OFF, 3: cls.PRIVATE}
20+
return mapping[index]
21+
22+
@classmethod
23+
def get_scene(cls, is_group: bool, is_unique_session: bool) -> "RstScene":
24+
if is_group:
25+
return cls.GROUP_UNIQUE_ON if is_unique_session else cls.GROUP_UNIQUE_OFF
26+
return cls.PRIVATE

0 commit comments

Comments
 (0)