mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-27 21:19:31 +01:00
Move 'exec' command into its separate plugin
This commit is contained in:
parent
3d621b00df
commit
d059bd4ff1
@ -6,20 +6,6 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
import utils
|
||||
from log import log
|
||||
|
||||
def _exec(irc, source, args):
|
||||
"""<code>
|
||||
|
||||
Admin-only. Executes <code> in the current PyLink instance.
|
||||
\x02**WARNING: THIS CAN BE DANGEROUS IF USED IMPROPERLY!**\x02"""
|
||||
utils.checkAuthenticated(irc, source, allowOper=False)
|
||||
args = ' '.join(args)
|
||||
if not args.strip():
|
||||
utils.msg(irc, source, 'No code entered!')
|
||||
return
|
||||
log.info('(%s) Executing %r for %s', irc.name, args, utils.getHostmask(irc, source))
|
||||
exec(args, globals(), locals())
|
||||
utils.add_cmd(_exec, 'exec')
|
||||
|
||||
@utils.add_cmd
|
||||
def spawnclient(irc, source, args):
|
||||
"""<nick> <ident> <host>
|
||||
|
21
plugins/exec.py
Executable file
21
plugins/exec.py
Executable file
@ -0,0 +1,21 @@
|
||||
# exec.py: Provides an 'exec' command to execute raw code
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
import utils
|
||||
from log import log
|
||||
|
||||
def _exec(irc, source, args):
|
||||
"""<code>
|
||||
|
||||
Admin-only. Executes <code> in the current PyLink instance.
|
||||
\x02**WARNING: THIS CAN BE DANGEROUS IF USED IMPROPERLY!**\x02"""
|
||||
utils.checkAuthenticated(irc, source, allowOper=False)
|
||||
args = ' '.join(args)
|
||||
if not args.strip():
|
||||
utils.msg(irc, source, 'No code entered!')
|
||||
return
|
||||
log.info('(%s) Executing %r for %s', irc.name, args, utils.getHostmask(irc, source))
|
||||
exec(args, globals(), locals())
|
||||
utils.add_cmd(_exec, 'exec')
|
Loading…
Reference in New Issue
Block a user