优化工单模块,增加企微模块

This commit is contained in:
mgw
2024-07-10 15:58:47 +08:00
parent e8512b23e4
commit 6b140fe6dd
134 changed files with 12830 additions and 2 deletions

View File

@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
import xmltodict
from wechatpy.messages import UnknownMessage
from wechatpy.utils import to_text
from wechatpy.enterprise.messages import MESSAGE_TYPES
from wechatpy.enterprise.events import EVENT_TYPES
def parse_message(xml):
if not xml:
return
message = xmltodict.parse(to_text(xml))['xml']
message_type = message['MsgType'].lower()
if message_type == 'event':
event_type = message['Event'].lower()
message_class = EVENT_TYPES.get(event_type, UnknownMessage)
else:
message_class = MESSAGE_TYPES.get(message_type, UnknownMessage)
return message_class(message)