Skip to content

Commit

Permalink
🐛 fix remove_tome default
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Sep 30, 2024
1 parent 19f89cc commit 772d96a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
12 changes: 6 additions & 6 deletions arclet/entari/command/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
class EntariCommands:
__namespace__ = "Entari"

def __init__(self, need_tome: bool = False, remove_tome: bool = False):
def __init__(self, need_tome: bool = False, remove_tome: bool = True):
self.trie: CharTrie = CharTrie()
self.publisher = Publisher("EntariCommands", MessageCreatedEvent)
self.publisher.providers.append(AlconnaProviderFactory())
Expand Down Expand Up @@ -114,7 +114,7 @@ def command(
command: str,
help_text: Optional[str] = None,
need_tome: bool = False,
remove_tome: bool = False,
remove_tome: bool = True,
auxiliaries: Optional[list[BaseAuxiliary]] = None,
providers: Optional[
list[Union[Provider, type[Provider], ProviderFactory, type[ProviderFactory]]]
Expand All @@ -131,7 +131,7 @@ def on(
self,
command: Alconna,
need_tome: bool = False,
remove_tome: bool = False,
remove_tome: bool = True,
auxiliaries: Optional[list[BaseAuxiliary]] = None,
providers: Optional[
list[Union[Provider, type[Provider], ProviderFactory, type[ProviderFactory]]]
Expand All @@ -143,7 +143,7 @@ def on(
self,
command: str,
need_tome: bool = False,
remove_tome: bool = False,
remove_tome: bool = True,
auxiliaries: Optional[list[BaseAuxiliary]] = None,
providers: Optional[
list[Union[Provider, type[Provider], ProviderFactory, type[ProviderFactory]]]
Expand All @@ -157,7 +157,7 @@ def on(
self,
command: Union[Alconna, str],
need_tome: bool = False,
remove_tome: bool = False,
remove_tome: bool = True,
auxiliaries: Optional[list[BaseAuxiliary]] = None,
providers: Optional[
list[Union[Provider, type[Provider], ProviderFactory, type[ProviderFactory]]]
Expand Down Expand Up @@ -209,7 +209,7 @@ def wrapper(func: TCallable) -> TCallable:
_commands = EntariCommands()


def config_commands(need_tome: bool = False, remove_tome: bool = False):
def config_commands(need_tome: bool = False, remove_tome: bool = True):
_commands.need_tome = need_tome
_commands.remove_tome = remove_tome

Expand Down
4 changes: 2 additions & 2 deletions arclet/entari/command/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(
plugin: Plugin,
command: Alconna,
need_tome: bool = False,
remove_tome: bool = False,
remove_tome: bool = True,
):
self.supplier = AlconnaSuppiler(command, need_tome, remove_tome)
super().__init__(plugin, MessageCreatedEvent)
Expand Down Expand Up @@ -49,7 +49,7 @@ def dispose(self):
Query = Query


def mount(cmd: Alconna, need_tome: bool = False, remove_tome: bool = False):
def mount(cmd: Alconna, need_tome: bool = False, remove_tome: bool = True):
if not (plugin := Plugin.current()):
raise LookupError("no plugin context found")
disp = AlconnaPluginDispatcher(plugin, cmd, need_tome, remove_tome)
Expand Down
30 changes: 16 additions & 14 deletions arclet/entari/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ class Event:
role: Role | None = attr()
user: User | None = attr()

_attrs: ClassVar[set[str]] = {
"argv",
"button",
"channel",
"guild",
"login",
"member",
"message",
"operator",
"role",
"user",
}

def __init__(self, account: Account, origin: SatoriEvent):
self.account = account
self._origin = origin
Expand All @@ -67,21 +80,10 @@ async def gather(self, context: Contexts):
context["$account"] = self.account
context["$origin_event"] = self._origin

for attrname in {
"argv",
"button",
"channel",
"guild",
"login",
"member",
"message",
"operator",
"role",
"user",
}:
value = getattr(self, attrname)
for name in self.__class__._attrs:
value = getattr(self, name)
if value is not None:
context["$message_origin" if attrname == "message" else attrname] = value
context["$message_origin" if name == "message" else name] = value

class AccountProvider(Provider[Account]):
async def __call__(self, context: Contexts):
Expand Down

0 comments on commit 772d96a

Please sign in to comment.