コード例 #1
0
 def videoMsg(self, msg, isGroupChat=False):
     mobj = EFBMsg(self)
     mobj.path, mobj.mime = self.save_file(msg, MsgType.Video)
     mobj.type = MsgType.Video
     mobj.text = None
     mobj.file = open(mobj.path, "rb")
     return mobj
コード例 #2
0
 def wechat_video_msg(self, msg):
     mobj = EFBMsg(self)
     mobj.path, mobj.mime = self.save_file(msg, MsgType.Video)
     mobj.type = MsgType.Video
     mobj.text = None
     mobj.file = open(mobj.path, "rb")
     return mobj
コード例 #3
0
 def fileMsg(self, msg, isGroupChat=False):
     mobj = EFBMsg(self)
     mobj.type = MsgType.File
     mobj.path, mobj.mime = self.save_file(msg, mobj.type)
     mobj.text = msg['FileName']
     mobj.file = open(mobj.path, "rb")
     return mobj
コード例 #4
0
 def wechat_voice_msg(self, msg):
     mobj = EFBMsg(self)
     mobj.type = MsgType.Audio
     mobj.path, mobj.mime = self.save_file(msg, mobj.type)
     mobj.text = None
     mobj.file = open(mobj.path, "rb")
     return mobj
コード例 #5
0
 def master_qr_code(self, uuid, status, qrcode):
     status = int(status)
     msg = EFBMsg(self)
     msg.type = MsgType.Text
     msg.source = MsgSource.System
     msg.origin = {
         'name': '%s Auth' % self.channel_name,
         'alias': '%s Auth' % self.channel_name,
         'uid': -1
     }
     if status == 201:
         msg.type = MsgType.Text
         msg.text = 'Tap "Confirm" to continue.'
     elif status == 200:
         msg.type = MsgType.Text
         msg.text = "Successfully authenticated."
     elif uuid != self.qr_uuid:
         msg.type = MsgType.Image
         path = os.path.join("storage", self.channel_id)
         if not os.path.exists(path):
             os.makedirs(path)
         path = os.path.join(path, 'QR-%s.jpg' % int(time.time()))
         self.logger.debug("master_qr_code file path: %s", path)
         qr_url = "https://login.weixin.qq.com/l/" + uuid
         QRCode(qr_url).png(path, scale=10)
         msg.text = 'Scan this QR Code with WeChat to continue.'
         msg.path = path
         msg.file = open(path, 'rb')
         msg.mime = 'image/jpeg'
     if status in (200, 201) or uuid != self.qr_uuid:
         self.queue.put(msg)
         self.qr_uuid = uuid
コード例 #6
0
 def pictureMsg(self, msg, isGroupChat=False):
     mobj = EFBMsg(self)
     mobj.type = MsgType.Image
     mobj.path, mime = self.save_file(msg, mobj.type)
     mobj.text = None
     mobj.file = open(mobj.path, "rb")
     mobj.mime = mime
     return mobj
コード例 #7
0
 def wechat_file_msg(self, msg):
     mobj = EFBMsg(self)
     mobj.type = MsgType.File
     mobj.path, mobj.mime = self.save_file(msg, mobj.type)
     mobj.text = msg['FileName']
     mobj.filename = msg['FileName'] or None
     mobj.file = open(mobj.path, "rb")
     return mobj
コード例 #8
0
 def wechat_picture_msg(self, msg):
     mobj = EFBMsg(self)
     mobj.type = MsgType.Image if msg['MsgType'] == 3 else MsgType.Sticker
     mobj.path, mime = self.save_file(msg, mobj.type)
     mobj.text = None
     mobj.file = open(mobj.path, "rb")
     mobj.mime = mime
     return mobj