Skip to content

Commit

Permalink
🐛 fix shell
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Nov 9, 2024
1 parent 89cf4de commit f9bf220
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions app/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from avilla.core import Context
from creart import it
from graia.broadcast.entities.dispatcher import BaseDispatcher
from graia.broadcast.exceptions import PropagationCancelled
from graia.broadcast.exceptions import PropagationCancelled, RequirementCrashed
from graia.broadcast.entities.signatures import Force
from graia.broadcast.interfaces.dispatcher import DispatcherInterface
from graia.saya import Saya
Expand Down Expand Up @@ -140,7 +140,10 @@ def __init__(self, service: RaianBotService):
self.service = service

async def beforeExecution(self, interface: DispatcherInterface):
context: Context = await interface.lookup_param("context", Context, Force(None))
try:
context = await interface.lookup_param("context", Context, Force(None))
except RequirementCrashed:
context = None
if context:
interface.local_storage["bot_config"] = next(
(bot for bot in self.service.config.bots if bot.ensure(context.account)), None # type: ignore
Expand Down
6 changes: 3 additions & 3 deletions plugins/shell/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

@listen(MessageReceived)
@permission("master")
@startswith("shell", bind="echos")
@startswith("shell")
@exclusive
@accessable
async def shell(ctx: Context, echos: MessageChain):
async def shell(ctx: Context, message: MessageChain):
process = await asyncio.create_subprocess_shell(
str(echos),
str(message).removeprefix("shell").strip(),
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
Expand Down

0 comments on commit f9bf220

Please sign in to comment.