Browse Source

获取图片用文件保存方式通用性不大,一般都是获取到数据解耦到另外一个程序执行,所以把这个加到消息体中,因为只有带session的cookies才能获取,所以内部获取就直接附加上

liuyang 8 years ago
parent
commit
ac092922c0
1 changed files with 2 additions and 0 deletions
  1. 2 0
      wxbot.py

+ 2 - 0
wxbot.py

@@ -437,12 +437,14 @@ class WXBot:
         elif mtype == 3:
             msg_content['type'] = 3
             msg_content['data'] = self.get_msg_img_url(msg_id)
+            msg_content['img']=self.session.get(msg_content['data']).content.encode('hex')
             if self.DEBUG:
                 image = self.get_msg_img(msg_id)
                 print '    %s[Image] %s' % (msg_prefix, image)
         elif mtype == 34:
             msg_content['type'] = 4
             msg_content['data'] = self.get_voice_url(msg_id)
+            msg_content['voice'] = self.session.get(msg_content['data']).content.encode('hex')
             if self.DEBUG:
                 voice = self.get_voice(msg_id)
                 print '    %s[Voice] %s' % (msg_prefix, voice)