From 9eecc6dd389b7b30184350f4ac435f2bba7daf59 Mon Sep 17 00:00:00 2001 From: Yuxin Wu Date: Thu, 9 Feb 2017 13:24:37 +0800 Subject: [PATCH] bug fix on chatroom msg handling --- README.md | 4 ++-- wechat/msg.py | 1 + wechat/parser.py | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a9eb9e9..2df9bcc 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,8 @@ On Debian/Ubuntu systems, these dependencies can be installed via: ```sh sudo apt-get install python-requests python-pil python-pyquery python-numpy libsox-dev -sudo pip install pysqlcipher csscompressor -sudo pip install --pre pysox +pip install --user pysqlcipher csscompressor +pip install --user --pre pysox ``` #### Get Necessary Data: diff --git a/wechat/msg.py b/wechat/msg.py index 46a63b6..a76bd0b 100644 --- a/wechat/msg.py +++ b/wechat/msg.py @@ -91,6 +91,7 @@ class WeChatMsg(object): return self.content elif self.type == TYPE_REDENVELOPE: pq = PyQuery(self.content_xml_ready, parser='xml') + title = pq('sendertitle').text() return u"[RED ENVELOPE]\n{}".format(title) else: diff --git a/wechat/parser.py b/wechat/parser.py index 916b7e6..8ffffd2 100644 --- a/wechat/parser.py +++ b/wechat/parser.py @@ -135,6 +135,7 @@ SELECT {} FROM message if values['chat'].endswith('@chatroom'): values['chat'] = self.contacts[values['chat']] content = values['content'] + if values['isSend'] == 1: values['talker'] = self.username elif values['type'] == TYPE_SYSTEM: @@ -142,7 +143,8 @@ SELECT {} FROM message else: talker = content[:content.find(':')] values['talker'] = self.contacts.get(talker, talker) - values['content'] = content[content.find('\n') + 1:] + + values['content'] = content[content.find('\n') + 1:] else: tk_id = values['talker'] values['chat'] = self.contacts[tk_id]