Skip to content
Permalink
Browse files

Update file processing logic

  • Loading branch information
blueset committed Sep 3, 2019
1 parent c7e4b3e commit 9d9c7712223dfd92d029e6d3bd922dec0cf09c9e
Showing with 11 additions and 1 deletion.
  1. +1 −0 .pre-commit-config.yaml
  2. +1 −1 efb_wechat_slave/__version__.py
  3. +9 −0 efb_wechat_slave/slave_message.py
@@ -22,6 +22,7 @@ repos:
entry: ./pre-commit
language: script
stages: [commit]
files: efb_wechat_slave/.+\.py
exclude_types: [pofile]
exclude: .+(__version__\.py|\.po)
pass_filenames: false
@@ -1,3 +1,3 @@
# coding: utf-8

__version__ = "2.0.0a29.dev1"
__version__ = "2.0.0a29.dev2"
@@ -290,7 +290,10 @@ def wechat_picture_msg(self, msg: wxpy.Message) -> EFBMsg:
try:
if msg.raw['MsgType'] == 47 and not msg.raw['Content']:
raise EOFError
if msg.file_size == 0:
raise EOFError
efb_msg.path, efb_msg.mime, efb_msg.file = self.save_file(msg)
efb_msg.filename = msg.file_name
# ^ Also throws EOFError
efb_msg.text = ""
except EOFError:
@@ -306,7 +309,10 @@ def wechat_sticker_msg(self, msg: wxpy.Message) -> EFBMsg:
try:
if msg.raw['MsgType'] == 47 and not msg.raw['Content']:
raise EOFError
if msg.file_size == 0:
raise EOFError
efb_msg.path, efb_msg.mime, efb_msg.file = self.save_file(msg)
efb_msg.filename = msg.file_name
# ^ Also throws EOFError
if 'gif' in efb_msg.mime and Image.open(efb_msg.path).is_animated:
efb_msg.type = MsgType.Animation
@@ -347,7 +353,10 @@ def wechat_video_msg(self, msg: wxpy.Message) -> EFBMsg:
efb_msg = EFBMsg()
efb_msg.type = MsgType.Video
try:
if msg.file_size == 0:
raise EOFError
efb_msg.path, efb_msg.mime, efb_msg.file = self.save_file(msg)
efb_msg.filename = msg.file_name
efb_msg.text = ""
except EOFError:
efb_msg.type = MsgType.Text

0 comments on commit 9d9c771

Please sign in to comment.
You can’t perform that action at this time.