How to use the wechatpy.parse_message function in wechatpy

To help you get started, we’ve selected a few wechatpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jxtech / wechatpy / tests / test_parser.py View on Github external
def test_parse_click_event(self):
        xml = """
        
        
        123456789
        
        
        
        """

        msg = parse_message(xml)

        self.assertEqual('event', msg.type)
        self.assertEqual('click', msg.event)
        self.assertEqual('EVENTKEY', msg.key)
github jxtech / wechatpy / tests / test_parser.py View on Github external
def test_parse_location_message(self):
        xml = """
        
        
        1351776360
        
        23.134521
        113.358803
        20
        <label></label>
        1234567890123456
        """

        msg = parse_message(xml)
        self.assertEqual('location', msg.type)
github jxtech / wechatpy / tests / test_parser.py View on Github external
def test_parse_link_message(self):
        xml = """
        
        
        1351776360
        
        <title>&lt;![CDATA[公众平台官网链接]]&gt;</title>
        
        
        1234567890123456
        """

        msg = parse_message(xml)
        self.assertEqual('link', msg.type)
github jxtech / wechatpy / tests / test_parser.py View on Github external
1475134700
        
        
        <title>&lt;![CDATA[样例公司抬头]]&gt;</title>
        
        
        
        
        
        
        
        """

        msg = parse_message(xml)
        self.assertTrue(isinstance(msg, SubmitInvoiceTitleEvent))
        self.assertEqual('样例公司抬头', msg.title)
        self.assertEqual('1486715661', msg.tax_no)
        self.assertEqual('abc', msg.addr)
        self.assertEqual('13313331333', msg.phone)
        self.assertEqual('bt', msg.bank_type)
        self.assertEqual('bn', msg.bank_no)
        self.assertEqual('at', msg.attach)
        self.assertEqual('InvoiceUserTitleBusinessType', msg.title_type)
github jxtech / wechatpy / tests / test_events.py View on Github external
1408090816
        
        
        
        1
        
        
        
        
        
        
        """

        event = parse_message(xml)

        self.assertTrue(isinstance(event, PicPhotoOrAlbumEvent))
        self.assertEqual(1, event.count)
        self.assertEqual(
            '5a75aaca956d97be686719218f275c6b',
            event.pictures[0]['PicMd5Sum']
        )
github jxtech / wechatpy / tests / test_events.py View on Github external
def test_kf_switch_session_event(self):
        from wechatpy.events import KfSwitchSessionEvent

        xml = """
        
        
        1399197672
        
        
        
        
        """

        event = parse_message(xml)
        self.assertTrue(isinstance(event, KfSwitchSessionEvent))
        self.assertEqual('test1@test', event.from_account)
        self.assertEqual('test2@test', event.to_account)
github jxtech / wechatpy / tests / test_parser.py View on Github external
def test_parse_scan_event(self):
        xml = """
        
        
        123456789
        
        
        
        
        """

        msg = parse_message(xml)

        self.assertEqual('event', msg.type)
        self.assertEqual('scan', msg.event)
        self.assertEqual('123123', msg.scene_id)
        self.assertEqual('TICKET', msg.ticket)
github jxtech / wechatpy / tests / test_events.py View on Github external
xml = """
        
        
        1408091189
        
        
        
        
        
        
        <label></label>
        
        
        """

        event = parse_message(xml)

        self.assertTrue(isinstance(event, LocationSelectEvent))
        self.assertEqual(('23', '113'), event.location)
        self.assertEqual('15', event.scale)
        self.assertTrue(event.poiname is None)
        self.assertEqual('广州市海珠区客村艺苑路 106号', event.label)
github saibei88 / wechat-router / handlers / wechathandlers.py View on Github external
def post(self):
        """接受微信服务器post的数据"""
#        print('Raw message: \n%s' % self.request.body)
        token_check()
#        crypto = WeChatCrypto(ACCESS_TOKEN, EncodingAESKey, APPID)
        try:
#      选择数据加密时候使用
#            msg = crypto.decrypt_message(
#                self.request.body,
#                msg_signature,
#                timestamp,
#                nonce
#                )
#            print('Descypted message: \n%s' % ms)
#            self.write("success")
            msg = parse_message(self.request.body)
            os.kill(os.getpid(), signal.SIGUSR1)
            self.cache.append(msg)
#            main.ChatSocketHandler.update_cache()
#            print "message time ",msg.time
            data_source = 1
            customer_name = msg.source
            content_type = msg.type
            create_time = datetime.datetime.fromtimestamp(msg.time)
            msg_id = msg.id
            content = ""
#  微信服务器post的数据链接可以直接回写回复信息,xml格式
            if msg.type == 'text':
#                print msg.content
                content = msg.content
                reply = create_reply(msg.content, msg)
                message_class = REPLY_TYPES.get("text")