1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Fix eval/exec commands on Royalnet 5.11

This commit is contained in:
Steffo 2020-08-23 23:55:29 +02:00
parent 4ba0469cf6
commit 421ad2daad
2 changed files with 10 additions and 8 deletions

View file

@ -12,10 +12,11 @@ class EvalCommand(rc.Command):
syntax: str = "{espressione}" syntax: str = "{espressione}"
async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None:
user: rbt.User = await data.get_author(error_if_none=True) async with data.session_acm() as session:
if "admin" not in user.roles: user: rbt.User = await data.find_author(session=session, required=True)
raise rc.CommandError("Non sei autorizzato a eseguire codice arbitrario!\n" if "admin" not in user.roles:
"(Sarebbe un po' pericoloso se te lo lasciassi eseguire, non trovi?)") raise rc.CommandError("Non sei autorizzato a eseguire codice arbitrario!\n"
"(Sarebbe un po' pericoloso se te lo lasciassi eseguire, non trovi?)")
try: try:
result = eval(args.joined(require_at_least=1)) result = eval(args.joined(require_at_least=1))
except Exception as e: except Exception as e:

View file

@ -12,10 +12,11 @@ class ExecCommand(rc.Command):
syntax: str = "{script}" syntax: str = "{script}"
async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None:
user: rbt.User = await data.get_author(error_if_none=True) async with data.session_acm() as session:
if "admin" not in user.roles: user: rbt.User = await data.find_author(session=session, required=True)
raise rc.CommandError("Non sei autorizzato a eseguire codice arbitrario!\n" if "admin" not in user.roles:
"(Sarebbe un po' pericoloso se te lo lasciassi eseguire, non trovi?)") raise rc.CommandError("Non sei autorizzato a eseguire codice arbitrario!\n"
"(Sarebbe un po' pericoloso se te lo lasciassi eseguire, non trovi?)")
try: try:
exec(args.joined(require_at_least=1)) exec(args.joined(require_at_least=1))
except Exception as e: except Exception as e: