mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-24 03:29:28 +01:00
exec: port to permissions API (#367)
This commit is contained in:
parent
5a066bfde4
commit
9e2598612a
@ -4,6 +4,7 @@ exec.py: Provides commands for executing raw code and debugging PyLink.
|
||||
|
||||
from pylinkirc import utils, world
|
||||
from pylinkirc.log import log
|
||||
from pylinkirc.coremods import permissions
|
||||
|
||||
# These imports are not strictly necessary, but make the following modules
|
||||
# easier to access through eval and exec.
|
||||
@ -17,8 +18,9 @@ def _exec(irc, source, args):
|
||||
"""<code>
|
||||
|
||||
Admin-only. Executes <code> in the current PyLink instance. This command performs backslash escaping of characters, so things like \\n and \\ will work.
|
||||
|
||||
\x02**WARNING: THIS CAN BE DANGEROUS IF USED IMPROPERLY!**\x02"""
|
||||
irc.checkAuthenticated(source, allowOper=False)
|
||||
permissions.checkPermissions(irc, source, ['exec.exec'])
|
||||
|
||||
# Allow using \n in the code, while escaping backslashes correctly otherwise.
|
||||
args = bytes(' '.join(args), 'utf-8').decode("unicode_escape")
|
||||
@ -36,8 +38,9 @@ def _eval(irc, source, args):
|
||||
"""<Python expression>
|
||||
|
||||
Admin-only. Evaluates the given Python expression and returns the result.
|
||||
|
||||
\x02**WARNING: THIS CAN BE DANGEROUS IF USED IMPROPERLY!**\x02"""
|
||||
irc.checkAuthenticated(source, allowOper=False)
|
||||
permissions.checkPermissions(irc, source, ['exec.eval'])
|
||||
|
||||
args = ' '.join(args)
|
||||
if not args.strip():
|
||||
@ -55,7 +58,7 @@ def raw(irc, source, args):
|
||||
|
||||
Admin-only. Sends raw text to the uplink IRC server.
|
||||
\x02**WARNING: THIS CAN BREAK YOUR NETWORK IF USED IMPROPERLY!**\x02"""
|
||||
irc.checkAuthenticated(source, allowOper=False)
|
||||
permissions.checkPermissions(irc, source, ['exec.raw'])
|
||||
|
||||
args = ' '.join(args)
|
||||
if not args.strip():
|
||||
@ -74,7 +77,7 @@ def inject(irc, source, args):
|
||||
|
||||
Admin-only. Injects raw text into the running PyLink protocol module, replying with the hook data returned.
|
||||
\x02**WARNING: THIS CAN BREAK YOUR NETWORK IF USED IMPROPERLY!**\x02"""
|
||||
irc.checkAuthenticated(source, allowOper=False)
|
||||
permissions.checkPermissions(irc, source, ['exec.inject'])
|
||||
|
||||
args = ' '.join(args)
|
||||
if not args.strip():
|
||||
|
Loading…
Reference in New Issue
Block a user