aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'ingrex/praser.py')
-rwxr-xr-xingrex/praser.py25
1 files changed, 25 insertions, 0 deletions
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 @@
1"Ingrex praser deal with message"
2from datetime import datetime, timedelta
3import platform
4import os
5import time
6
7osname = platform.system()
8if osname == "Linux":
9 os.environ['TZ'] = 'Asia/Shanghai'
10 time.tzset()
11
12class Message(object):
13 "Message object"
14 def __init__(self, raw_msg):
15 self.raw = raw_msg
16 self.guid = raw_msg[0]
17 self.timestamp = raw_msg[1]
18 seconds, millis = divmod(raw_msg[1], 1000)
19 time = datetime.fromtimestamp(seconds) + timedelta(milliseconds=millis)
20 self.time = time.strftime('%Y/%m/%d %H:%M:%S:%f')[:-3]
21 self.text = raw_msg[2]['plext']['text']
22 self.ptype = raw_msg[2]['plext']['plextType']
23 self.team = raw_msg[2]['plext']['team']
24 self.type = raw_msg[2]['plext']['markup'][1][1]['plain']
25
Powered by cgit v1.2.3 (git 2.41.0)