From 707a881931a12f10c642042781933fbbb5e29c02 Mon Sep 17 00:00:00 2001 From: nicobo Date: Tue, 26 May 2020 23:15:53 +0200 Subject: [PATCH] + returns the status as a dict for simpler usage from other Python programs --- nicobot/askbot.py | 2 ++ nicobot/transbot.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/nicobot/askbot.py b/nicobot/askbot.py index 88069b4..313edba 100644 --- a/nicobot/askbot.py +++ b/nicobot/askbot.py @@ -191,6 +191,8 @@ def run( args=sys.argv[1:] ): # NOTE ensure_ascii=False + encode('utf-8').decode() is not mandatory but allows printing plain UTF-8 strings rather than \u... or \x... # NOTE default=repr is mandatory because some objects in the args are not serializable print( json.dumps(status,skipkeys=True,ensure_ascii=False,default=repr).encode('utf-8').decode(), file=sys.stdout, flush=True ) + # Still returns the full status for simpler handling in Python + return status if __name__ == '__main__': diff --git a/nicobot/transbot.py b/nicobot/transbot.py index 4b5c977..3f6e8ac 100755 --- a/nicobot/transbot.py +++ b/nicobot/transbot.py @@ -694,6 +694,8 @@ def run( args=sys.argv[1:] ): # NOTE ensure_ascii=False + encode('utf-8').decode() is not mandatory but allows printing plain UTF-8 strings rather than \u... or \x... # NOTE default=repr is mandatory because some objects in the args are not serializable print( json.dumps(status,skipkeys=True,ensure_ascii=False,default=repr).encode('utf-8').decode(), file=sys.stdout, flush=True ) + # Still returns the full status for simpler handling in Python + return status if __name__ == '__main__':