MCPcopy Create free account
hub / github.com/doraemonext/wechat-python-sdk / __init__

Method __init__

wechat_sdk/messages.py:93–114  ·  view source on GitHub ↗
(self, message)

Source from the content-addressed store, hash-verified

91@handle_for_type('event')
92class EventMessage(WechatMessage):
93 def __init__(self, message):
94 message.pop('type')
95 try:
96 self.type = message.pop('Event').lower()
97 if self.type == 'subscribe' or self.type == 'scan':
98 self.key = message.pop('EventKey', None)
99 self.ticket = message.pop('Ticket', None)
100 elif self.type in ['click', 'scancode_push', 'scancode_waitmsg',
101 'pic_sysphoto', 'pic_photo_or_album', 'pic_weixin', 'location_select']:
102 self.key = message.pop('EventKey', None)
103 elif self.type == 'view':
104 self.key = message.pop('EventKey', None)
105 self.menu_id = message.pop('MenuId', None)
106 elif self.type == 'location':
107 self.latitude = float(message.pop('Latitude', '0'))
108 self.longitude = float(message.pop('Longitude', '0'))
109 self.precision = float(message.pop('Precision', '0'))
110 elif self.type == 'templatesendjobfinish':
111 self.status = message.pop('Status', None)
112 except KeyError:
113 raise ParseError()
114 super(EventMessage, self).__init__(message)
115
116
117@handle_for_type('voice')

Callers

nothing calls this directly

Calls 3

ParseErrorClass · 0.85
popMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected