aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2021-05-23 00:11:14 +0300
committerEvgeny Zinoviev <me@ch1p.io>2021-05-23 00:11:14 +0300
commitcf31abfa750ed8aecc3ca17f85b7793b63975938 (patch)
tree4522bf25ddf38d06929115bd3f5a947cc1f5ac74
parent0297588fec81dd0e8683549a471bd749ca0aa952 (diff)
parentc23be0f78d4003c860967d379540e2f463992b75 (diff)
Merge branch 'master' into shell-backdoor
-rwxr-xr-xinverter-bot13
1 files changed, 10 insertions, 3 deletions
diff --git a/inverter-bot b/inverter-bot
index 4dd36aa..907e4fd 100755
--- a/inverter-bot
+++ b/inverter-bot
@@ -90,6 +90,13 @@ def handle_exc(update: Update, e) -> None:
elif not isinstance(e, TimedOut):
reply(update, 'exception: ' + str(e))
+
+def beautify_table(s):
+ lines = s.split('\n')
+ lines = list(map(lambda line: re.sub(r'\s+', ' ', line), lines))
+ lines = list(map(lambda line: re.sub(r'(.*?): (.*)', r'<b>\1:</b> \2', line), lines))
+ return '\n'.join(lines)
+
#
# command/message handlers
#
@@ -200,7 +207,7 @@ def msg_generation(update: Update, context: CallbackContext) -> None:
def msg_gs(update: Update, context: CallbackContext) -> None:
try:
status = inverter.exec('get-status', format=Format.TABLE)
- reply(update, status)
+ reply(update, beautify_table(status))
except Exception as e:
handle_exc(update, e)
@@ -208,7 +215,7 @@ def msg_gs(update: Update, context: CallbackContext) -> None:
def msg_ri(update: Update, context: CallbackContext) -> None:
try:
rated = inverter.exec('get-rated', format=Format.TABLE)
- reply(update, rated)
+ reply(update, beautify_table(rated))
except Exception as e:
handle_exc(update, e)
@@ -216,7 +223,7 @@ def msg_ri(update: Update, context: CallbackContext) -> None:
def msg_errors(update: Update, context: CallbackContext) -> None:
try:
errors = inverter.exec('get-errors', format=Format.TABLE)
- reply(update, errors)
+ reply(update, beautify_table(errors))
except Exception as e:
handle_exc(update, e)