Completed
Push — master ( ae9180...fd0ef0 )
by Wu
33s
created

UserScanProductVerifyActionEvent   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 6
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
2
3
import six
4
from werobot.messages.entries import StringEntry, IntEntry, FloatEntry
5
from werobot.messages.base import WeRoBotMetaClass
6
7
8
class EventMetaClass(WeRoBotMetaClass):
9
    pass
10
11
12
@six.add_metaclass(EventMetaClass)
13
class WeChatEvent(object):
14
    target = StringEntry('ToUserName')
15
    source = StringEntry('FromUserName')
16
    time = IntEntry('CreateTime')
17
    message_id = IntEntry('MsgID', 0)
18
19
    def __init__(self, message):
20
        self.__dict__.update(message)
21
22
23
class SimpleEvent(WeChatEvent):
24
    key = StringEntry('EventKey')
25
26
27
class TicketEvent(WeChatEvent):
28
    key = StringEntry('EventKey')
29
    ticket = StringEntry('Ticket')
30
31
32
class SubscribeEvent(TicketEvent):
33
    __type__ = 'subscribe_event'
34
35
36
class UnSubscribeEvent(WeChatEvent):
37
    __type__ = 'unsubscribe_event'
38
39
40
class ScanEvent(TicketEvent):
41
    __type__ = 'scan_event'
42
43
44
class ScanCodePushEvent(SimpleEvent):
45
    __type__ = 'scancode_push_event'
46
    scan_type = StringEntry('ScanCodeInfo.ScanType')
47
    scan_result = StringEntry('ScanCodeInfo.ScanResult')
48
49
50
class ScanCodeWaitMsgEvent(ScanCodePushEvent):
51
    __type__ = 'scancode_waitmsg_event'
52
    scan_type = StringEntry('ScanCodeInfo.ScanType')
53
    scan_result = StringEntry('ScanCodeInfo.ScanResult')
54
55
56
class BasePicEvent(SimpleEvent):
57
    count = IntEntry('SendPicsInfo.Count')
58
59
    def __init__(self, message):
60
        super(BasePicEvent, self).__init__(message)
61
        self.pic_list = list()
62
        if self.count > 1:
63
            for item in message['SendPicsInfo']['PicList'].pop('item'):
64
                self.pic_list.append({'pic_md5_sum': item['PicMd5Sum']})
65
        else:
66
            self.pic_list.append(
67
                {'pic_md5_sum': message['SendPicsInfo']['PicList'].pop('item')['PicMd5Sum']}
68
            )
69
70
71
class PicSysphotoEvent(BasePicEvent):
72
    __type__ = 'pic_sysphoto_event'
73
74
75
class PicPhotoOrAlbumEvent(BasePicEvent):
76
    __type__ = 'pic_photo_or_album_event'
77
78
79
class PicWeixinEvent(BasePicEvent):
80
    __type__ = 'pic_weixin_event'
81
82
83
class LocationSelectEvent(SimpleEvent):
84
    __type__ = 'location_select_event'
85
    location_x = StringEntry('SendLocationInfo.Location_X')
86
    location_y = StringEntry('SendLocationInfo.Location_Y')
87
    scale = StringEntry('SendLocationInfo.Scale')
88
    label = StringEntry('SendLocationInfo.Label')
89
    poi_name = StringEntry('SendLocationInfo.Poiname')
90
91
92
class ClickEvent(SimpleEvent):
93
    __type__ = 'click_event'
94
95
96
class ViewEvent(SimpleEvent):
97
    __type__ = 'view_event'
98
99
100
class LocationEvent(WeChatEvent):
101
    __type__ = 'location_event'
102
    latitude = FloatEntry('Latitude')
103
    longitude = FloatEntry('Longitude')
104
    precision = FloatEntry('Precision')
105
106
107
class TemplateSendJobFinishEvent(WeChatEvent):
108
    __type__ = 'templatesendjobfinish_event'
109
    status = StringEntry('Status')
110
111
112
class BaseProductEvent(WeChatEvent):
113
    key_standard = StringEntry('KeyStandard')
114
    key_str = StringEntry('KeyStr')
115
    ext_info = StringEntry('ExtInfo')
116
117
118
class UserScanProductEvent(BaseProductEvent):
119
    __type__ = 'user_scan_product_event'
120
    country = StringEntry('Country')
121
    province = StringEntry('Province')
122
    city = StringEntry('City')
123
    sex = IntEntry('Sex')
124
    scene = IntEntry('Scene')
125
126
127
class UserScanProductEnterSessionEvent(BaseProductEvent):
128
    __type__ = 'user_scan_product_enter_session_event'
129
130
131
class UserScanProductAsyncEvent(BaseProductEvent):
132
    __type__ = 'user_scan_product_async_event'
133
    region_code = StringEntry('RegionCode')
134
135
136
class UserScanProductVerifyActionEvent(WeChatEvent):
137
    __type__ = 'user_scan_product_verify_action_event'
138
    key_standard = StringEntry('KeyStandard')
139
    key_str = StringEntry('KeyStr')
140
    result = StringEntry('Result')
141
    reason_msg = StringEntry('ReasonMsg')
142
143
144
class UnknownEvent(WeChatEvent):
145
    __type__ = 'unknown_event'
146