Skip to content

Commit

Permalink
✨ 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Mar 1, 2022
1 parent 197f931 commit 41bcd80
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions arclet/alconna/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,19 @@ def register(self, command: "Alconna") -> None:
else:
raise DuplicateCommand("命令已存在")

def require(self, command: str) -> "Analyser":
def require(self, command: Union["Alconna", str]) -> "Analyser":
"""获取解析器"""
namespace, name = self._command_part(command)
try:
ana = self.__commands[namespace][name]
except KeyError:
raise ValueError("命令不存在")
return ana
if isinstance(command, str):
namespace, name = self._command_part(command)
try:
ana = self.__commands[namespace][name]
except KeyError:
raise ValueError("命令不存在")
return ana
else:
cid = command.name.replace(self.sign, "")
namespace = command.namespace
return self.__commands[namespace][cid]

def delete(self, command: Union["Alconna", str]) -> None:
"""删除命令"""
Expand Down

0 comments on commit 41bcd80

Please sign in to comment.