summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/Reaktor/scripts
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2018-03-28 21:16:03 +0200
committerlassulus <lassulus@lassul.us>2018-03-28 21:29:57 +0200
commit22f33b8e99cf9ffe575905370df736ddc3517338 (patch)
treee0ea48202828b3b1154b5777fad0c1120e09bd90 /krebs/5pkgs/simple/Reaktor/scripts
parent1b050f22d44711c4f296c6bba371528d0cf44cf9 (diff)
reaktor-plugins sed: limit output
Diffstat (limited to 'krebs/5pkgs/simple/Reaktor/scripts')
-rw-r--r--krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py b/krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py
index da8e2f726..51ac7a071 100644
--- a/krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py
+++ b/krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py
@@ -18,20 +18,27 @@ def is_regex(line):
myre = re.compile(r'^s/(?:\\/|[^/])+/(?:\\/|[^/])*/[ig]?$')
return myre.match(line)
+
line = argv[1]
if is_regex(line):
last = d.get(usr, None)
if last:
from subprocess import Popen, PIPE
- p = Popen(['sed', line], stdin=PIPE, stdout=PIPE)
+ p = Popen(['sed', line], stdin=PIPE, stdout=PIPE, stderr=PIPE)
so, se = p.communicate(bytes("{}\n".format(last), "UTF-8"))
if p.returncode:
- print("something went wrong when trying to process your regex: {}".format(se.decode()))
+ print("something went wrong when trying to process your regex: {}".format(line.strip()))
ret = so.decode()
- print("\x1b[1m{}\x1b[0m meant: {}".format(usr, ret.strip()))
- if ret:
- d[usr] = ret
+ if len(ret) > 512:
+ print('message to long, skipped')
+ elif len(ret.split('\n')) > 5:
+ print('to many lines, skipped')
+ else:
+ if last.strip() != ret.strip():
+ print("\x1b[1m{}\x1b[0m meant: {}".format(usr, ret.strip()))
+ if ret:
+ d[usr] = ret
else:
print("no last message")