From cb52be3055b9ef05b5d1ead9431fdd69834ee3ba Mon Sep 17 00:00:00 2001 From: Jinwei Zhao Date: Mon, 2 Jan 2017 22:05:44 +0800 Subject: init --- ingrex/praser.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 ingrex/praser.py (limited to 'ingrex/praser.py') diff --git a/ingrex/praser.py b/ingrex/praser.py new file mode 100755 index 0000000..732ab1b --- /dev/null +++ b/ingrex/praser.py @@ -0,0 +1,25 @@ +"Ingrex praser deal with message" +from datetime import datetime, timedelta +import platform +import os +import time + +osname = platform.system() +if osname == "Linux": + os.environ['TZ'] = 'Asia/Shanghai' + time.tzset() + +class Message(object): + "Message object" + def __init__(self, raw_msg): + self.raw = raw_msg + self.guid = raw_msg[0] + self.timestamp = raw_msg[1] + seconds, millis = divmod(raw_msg[1], 1000) + time = datetime.fromtimestamp(seconds) + timedelta(milliseconds=millis) + self.time = time.strftime('%Y/%m/%d %H:%M:%S:%f')[:-3] + self.text = raw_msg[2]['plext']['text'] + self.ptype = raw_msg[2]['plext']['plextType'] + self.team = raw_msg[2]['plext']['team'] + self.type = raw_msg[2]['plext']['markup'][1][1]['plain'] + -- cgit v1.2.3