3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

Split the 'raw' command into a new plugin

Closes #565.
This commit is contained in:
James Lu 2018-01-21 13:50:37 -08:00
parent e446e0e27b
commit 8000d51453
3 changed files with 39 additions and 20 deletions

View File

@ -508,6 +508,10 @@ plugins:
# Servermaps plugin: displays network /map's from the PyLink server's perspective.
#- servermaps
# Raw plugin: Provides a 'raw' command for sending raw text to IRC.
# Not supported outside Clientbot networks!
#- raw
logging:
# This configuration block defines targets that PyLink should log commands,
# errors, etc., to.

View File

@ -135,26 +135,6 @@ def pieval(irc, source, args):
"""
_eval(irc, source, args, locals_dict=exec_locals_dict, pretty_print=True)
@utils.add_cmd
def raw(irc, source, args):
"""<text>
Admin-only. Sends raw text to the uplink IRC server.
\x02**WARNING: THIS CAN BREAK YOUR NETWORK IF USED IMPROPERLY!**\x02"""
permissions.check_permissions(irc, source, ['exec.raw'])
args = ' '.join(args)
if not args.strip():
irc.reply('No text entered!')
return
log.debug('(%s) Sending raw text %r to IRC for %s', irc.name, args,
irc.get_hostmask(source))
irc.send(args)
irc.reply("Done.")
@utils.add_cmd
def inject(irc, source, args):
"""<text>

35
plugins/raw.py Normal file
View File

@ -0,0 +1,35 @@
"""
raw.py: Provides a 'raw' command for sending raw text to IRC.
"""
from pylinkirc.log import log
from pylinkirc.coremods import permissions
from pylinkirc import utils
@utils.add_cmd
def raw(irc, source, args):
"""<text>
Sends raw text to the IRC server.
This command is not officially supported on non-Clientbot networks, where it
requires a separate permission."""
if irc.protoname == 'clientbot':
# exec.raw is included for backwards compatibility with PyLink 1.x
perms = ['raw.raw', 'exec.raw']
else:
perms = ['raw.raw.unsupported_network']
permissions.check_permissions(irc, source, perms)
args = ' '.join(args)
if not args.strip():
irc.reply('No text entered!')
return
# Note: This is loglevel debug so that we don't risk leaking things like
# NickServ passwords on Clientbot networks.
log.debug('(%s) Sending raw text %r to IRC for %s', irc.name, args,
irc.get_hostmask(source))
irc.send(args)
irc.reply("Done.")