From 05ca457946913bdd5bd0062bf8c8f468af6f2c78 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Fri, 5 May 2017 11:39:51 +0200 Subject: [PATCH] Added a helper function `strip_to_json` --- fbchat/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fbchat/utils.py b/fbchat/utils.py index d8d3e65..fdf2580 100644 --- a/fbchat/utils.py +++ b/fbchat/utils.py @@ -14,8 +14,11 @@ USER_AGENTS = [ def now(): return int(time()*1000) +def strip_to_json(text): + return re.sub(r"^[^{]*", '', text, 1); + def get_json(text): - return json.loads(re.sub(r"^[^{]*", '', text, 1)) + return json.loads(strip_to_json(text)) def digit_to_char(digit): if digit < 10: