From 28609135623c614f77c456c698f817096fa807cc Mon Sep 17 00:00:00 2001 From: James Lu Date: Wed, 30 May 2018 12:46:23 -0700 Subject: [PATCH] exec: use a longer length limit when called in private TODO: these should be made into proper config variables per #612 --- plugins/exec.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/exec.py b/plugins/exec.py index 24e36df..2aa1ca1 100644 --- a/plugins/exec.py +++ b/plugins/exec.py @@ -16,7 +16,9 @@ import pylinkirc import importlib exec_locals_dict = {} +# FIXME: make these config vars. PPRINT_MAX_LINES = 20 +PPRINT_MAX_LINES_PRIVATE = 200 PPRINT_WIDTH = 200 def _exec(irc, source, args, locals_dict=None): @@ -92,9 +94,12 @@ def _eval(irc, source, args, locals_dict=None, pretty_print=False): if pretty_print: lines = pprint.pformat(result, width=PPRINT_WIDTH, compact=True).splitlines() - for line in lines[:PPRINT_MAX_LINES]: + + maxlines = PPRINT_MAX_LINES if irc.is_channel(irc.called_in) else PPRINT_MAX_LINES_PRIVATE + + for line in lines[:maxlines]: irc.reply(line) - if len(lines) > PPRINT_MAX_LINES: + if len(lines) > maxlines: irc.reply('Suppressing %s more line(s) of output.' % (len(lines) - PPRINT_MAX_LINES)) else: # Purposely disable text wrapping so results are cut instead of potentially flooding;