1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
|
3
|
15 |
|
import six |
4
|
15 |
|
from werobot.messages.entries import StringEntry, IntEntry, FloatEntry |
5
|
|
|
from werobot.messages.base import WeRoBotMetaClass |
6
|
15 |
|
|
7
|
|
|
|
8
|
|
|
class EventMetaClass(WeRoBotMetaClass): |
9
|
15 |
|
pass |
10
|
15 |
|
|
11
|
15 |
|
|
12
|
|
|
@six.add_metaclass(EventMetaClass) |
13
|
15 |
|
class WeChatEvent(object): |
14
|
15 |
|
target = StringEntry('ToUserName') |
15
|
15 |
|
source = StringEntry('FromUserName') |
16
|
|
|
time = IntEntry('CreateTime') |
17
|
|
|
message_id = IntEntry('MsgID', 0) |
18
|
|
|
|
19
|
15 |
|
def __init__(self, message): |
20
|
15 |
|
self.__dict__.update(message) |
21
|
|
|
|
22
|
|
|
|
23
|
15 |
|
class SimpleEvent(WeChatEvent): |
24
|
15 |
|
key = StringEntry('EventKey') |
25
|
15 |
|
|
26
|
15 |
|
|
27
|
15 |
|
class TicketEvent(WeChatEvent): |
28
|
|
|
key = StringEntry('EventKey') |
29
|
15 |
|
ticket = StringEntry('Ticket') |
30
|
15 |
|
|
31
|
|
|
|
32
|
|
|
class SubscribeEvent(TicketEvent): |
33
|
15 |
|
__type__ = 'subscribe_event' |
34
|
15 |
|
|
35
|
15 |
|
|
36
|
|
|
class UnSubscribeEvent(WeChatEvent): |
37
|
|
|
__type__ = 'unsubscribe_event' |
38
|
15 |
|
|
39
|
15 |
|
|
40
|
|
|
class ScanEvent(TicketEvent): |
41
|
|
|
__type__ = 'scan_event' |
42
|
15 |
|
|
43
|
15 |
|
|
44
|
|
|
class ScanCodePushEvent(SimpleEvent): |
45
|
|
|
__type__ = 'scancode_push_event' |
46
|
15 |
|
scan_type = StringEntry('ScanCodeInfo.ScanType') |
47
|
15 |
|
scan_result = StringEntry('ScanCodeInfo.ScanResult') |
48
|
|
|
|
49
|
|
|
|
50
|
15 |
|
class ScanCodeWaitMsgEvent(ScanCodePushEvent): |
51
|
15 |
|
__type__ = 'scancode_waitmsg_event' |
52
|
|
|
scan_type = StringEntry('ScanCodeInfo.ScanType') |
53
|
|
|
scan_result = StringEntry('ScanCodeInfo.ScanResult') |
54
|
15 |
|
|
55
|
15 |
|
|
56
|
|
|
class BasePicEvent(SimpleEvent): |
57
|
|
|
count = IntEntry('SendPicsInfo.Count') |
58
|
15 |
|
|
59
|
15 |
|
def __init__(self, message): |
60
|
|
|
super(BasePicEvent, self).__init__(message) |
61
|
|
|
self.pic_list = list() |
62
|
15 |
|
if self.count > 1: |
63
|
15 |
|
for item in message['SendPicsInfo']['PicList'].pop('item'): |
64
|
15 |
|
self.pic_list.append({'pic_md5_sum': item['PicMd5Sum']}) |
65
|
15 |
|
else: |
66
|
15 |
|
self.pic_list.append( |
67
|
|
|
{ |
68
|
|
|
'pic_md5_sum': message['SendPicsInfo']['PicList'] |
69
|
15 |
|
.pop('item')['PicMd5Sum'] |
70
|
15 |
|
} |
71
|
|
|
) |
72
|
|
|
|
73
|
|
|
|
74
|
|
|
class PicSysphotoEvent(BasePicEvent): |
75
|
|
|
__type__ = 'pic_sysphoto_event' |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
class PicPhotoOrAlbumEvent(BasePicEvent): |
79
|
|
|
__type__ = 'pic_photo_or_album_event' |
80
|
|
|
|
81
|
|
|
|
82
|
|
|
class PicWeixinEvent(BasePicEvent): |
83
|
|
|
__type__ = 'pic_weixin_event' |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
class LocationSelectEvent(SimpleEvent): |
87
|
|
|
__type__ = 'location_select_event' |
88
|
|
|
location_x = StringEntry('SendLocationInfo.Location_X') |
89
|
|
|
location_y = StringEntry('SendLocationInfo.Location_Y') |
90
|
|
|
scale = StringEntry('SendLocationInfo.Scale') |
91
|
|
|
label = StringEntry('SendLocationInfo.Label') |
92
|
|
|
poi_name = StringEntry('SendLocationInfo.Poiname') |
93
|
|
|
|
94
|
|
|
|
95
|
|
|
class ClickEvent(SimpleEvent): |
96
|
|
|
__type__ = 'click_event' |
97
|
|
|
|
98
|
|
|
|
99
|
|
|
class ViewEvent(SimpleEvent): |
100
|
|
|
__type__ = 'view_event' |
101
|
|
|
|
102
|
|
|
|
103
|
|
|
class LocationEvent(WeChatEvent): |
104
|
|
|
__type__ = 'location_event' |
105
|
|
|
latitude = FloatEntry('Latitude') |
106
|
|
|
longitude = FloatEntry('Longitude') |
107
|
|
|
precision = FloatEntry('Precision') |
108
|
|
|
|
109
|
|
|
|
110
|
|
|
class TemplateSendJobFinishEvent(WeChatEvent): |
111
|
|
|
__type__ = 'templatesendjobfinish_event' |
112
|
|
|
status = StringEntry('Status') |
113
|
|
|
|
114
|
|
|
|
115
|
|
|
class BaseProductEvent(WeChatEvent): |
116
|
|
|
key_standard = StringEntry('KeyStandard') |
117
|
|
|
key_str = StringEntry('KeyStr') |
118
|
|
|
ext_info = StringEntry('ExtInfo') |
119
|
|
|
|
120
|
|
|
|
121
|
|
|
class UserScanProductEvent(BaseProductEvent): |
122
|
|
|
__type__ = 'user_scan_product_event' |
123
|
|
|
country = StringEntry('Country') |
124
|
|
|
province = StringEntry('Province') |
125
|
|
|
city = StringEntry('City') |
126
|
|
|
sex = IntEntry('Sex') |
127
|
|
|
scene = IntEntry('Scene') |
128
|
|
|
|
129
|
|
|
|
130
|
|
|
class UserScanProductEnterSessionEvent(BaseProductEvent): |
131
|
|
|
__type__ = 'user_scan_product_enter_session_event' |
132
|
|
|
|
133
|
|
|
|
134
|
|
|
class UserScanProductAsyncEvent(BaseProductEvent): |
135
|
|
|
__type__ = 'user_scan_product_async_event' |
136
|
|
|
region_code = StringEntry('RegionCode') |
137
|
|
|
|
138
|
|
|
|
139
|
|
|
class UserScanProductVerifyActionEvent(WeChatEvent): |
140
|
|
|
__type__ = 'user_scan_product_verify_action_event' |
141
|
|
|
key_standard = StringEntry('KeyStandard') |
142
|
|
|
key_str = StringEntry('KeyStr') |
143
|
|
|
result = StringEntry('Result') |
144
|
|
|
reason_msg = StringEntry('ReasonMsg') |
145
|
|
|
|
146
|
|
|
|
147
|
|
|
class BaseCardCheckEvent(WeChatEvent): |
148
|
|
|
card_id = StringEntry('CardId') |
149
|
|
|
refuse_reason = StringEntry('RefuseReason') |
150
|
|
|
|
151
|
|
|
|
152
|
|
|
class CardPassCheckEvent(BaseCardCheckEvent): |
153
|
|
|
__type__ = 'card_pass_check_event' |
154
|
|
|
|
155
|
|
|
|
156
|
|
|
class CardNotPassCheckEvent(BaseCardCheckEvent): |
157
|
|
|
__type__ = 'card_not_pass_check_event' |
158
|
|
|
|
159
|
|
|
|
160
|
|
|
class BaseCardEvent(WeChatEvent): |
161
|
|
|
card_id = StringEntry('CardId') |
162
|
|
|
user_card_code = StringEntry('UserCardCode') |
163
|
|
|
|
164
|
|
|
|
165
|
|
|
class UserGetCardEvent(BaseCardEvent): |
166
|
|
|
__type__ = 'user_get_card_event' |
167
|
|
|
is_give_by_friend = IntEntry('IsGiveByFriend') |
168
|
|
|
friend_user_name = StringEntry('FriendUserName') |
169
|
|
|
outer_id = IntEntry('OuterId') |
170
|
|
|
old_user_card_code = StringEntry('OldUserCardCode') |
171
|
|
|
outer_str = StringEntry('OuterStr') |
172
|
|
|
is_restore_member_card = IntEntry('IsRestoreMemberCard') |
173
|
|
|
is_recommend_by_friend = IntEntry('IsRecommendByFriend') |
174
|
|
|
|
175
|
|
|
|
176
|
|
|
class UserGiftingCardEvent(BaseCardEvent): |
177
|
|
|
__type__ = 'user_gifting_card_event' |
178
|
|
|
is_return_back = IntEntry('IsReturnBack') |
179
|
|
|
friend_user_name = StringEntry('FriendUserName') |
180
|
|
|
is_chat_room = IntEntry('IsChatRoom') |
181
|
|
|
|
182
|
|
|
|
183
|
|
|
class UserDelCardEvent(BaseCardEvent): |
184
|
|
|
__type__ = 'user_del_card_event' |
185
|
|
|
|
186
|
|
|
|
187
|
|
|
class UserConsumeCardEvent(BaseCardEvent): |
188
|
|
|
__type__ = 'user_consume_card_event' |
189
|
|
|
consume_source = StringEntry('ConsumeSource') |
190
|
|
|
location_name = StringEntry('LocationName') |
191
|
|
|
staff_open_id = StringEntry('StaffOpenId') |
192
|
|
|
verify_code = StringEntry('VerifyCode') |
193
|
|
|
remark_amount = StringEntry('RemarkAmount') |
194
|
|
|
outer_str = StringEntry('OuterStr') |
195
|
|
|
|
196
|
|
|
|
197
|
|
|
class UserPayFromPayCellEvent(BaseCardEvent): |
198
|
|
|
__type__ = 'user_pay_from_pay_cell_event' |
199
|
|
|
trans_id = StringEntry('TransId') |
200
|
|
|
location_id = IntEntry('LocationId') |
201
|
|
|
fee = StringEntry('Fee') |
202
|
|
|
original_fee = StringEntry('OriginalFee') |
203
|
|
|
|
204
|
|
|
|
205
|
|
|
class UserViewCardEvent(BaseCardEvent): |
206
|
|
|
__type__ = 'user_view_card_event' |
207
|
|
|
outer_str = StringEntry('OuterStr') |
208
|
|
|
|
209
|
|
|
|
210
|
|
|
class UserEnterSessionFromCardEvent(BaseCardEvent): |
211
|
|
|
__type__ = 'user_enter_session_from_card_event' |
212
|
|
|
|
213
|
|
|
|
214
|
|
|
class UpdateMemberCardEvent(BaseCardEvent): |
215
|
|
|
__type__ = 'update_member_card_event' |
216
|
|
|
modify_bonus = IntEntry('ModifyBonus') |
217
|
|
|
modify_balance = IntEntry('ModifyBalance') |
218
|
|
|
|
219
|
|
|
|
220
|
|
|
class CardSkuRemindEvent(WeChatEvent): |
221
|
|
|
__type__ = 'card_sku_remind_event' |
222
|
|
|
card_id = StringEntry('CardId') |
223
|
|
|
detail = StringEntry('Detail') |
224
|
|
|
|
225
|
|
|
|
226
|
|
|
class CardPayOrderEvent(WeChatEvent): |
227
|
|
|
__type__ = 'card_pay_order_event' |
228
|
|
|
order_id = StringEntry('OrderId') |
229
|
|
|
status = StringEntry('Status') |
230
|
|
|
create_order_time = IntEntry('CreateOrderTime') |
231
|
|
|
pay_finish_time = IntEntry('PayFinishTime') |
232
|
|
|
desc = StringEntry('Desc') |
233
|
|
|
free_coin_count = StringEntry('FreeCoinCount') |
234
|
|
|
pay_coin_count = StringEntry('PayCoinCount') |
235
|
|
|
refund_free_coin_count = StringEntry('RefundFreeCoinCount') |
236
|
|
|
refund_pay_coin_count = StringEntry('RefundPayCoinCount') |
237
|
|
|
order_type = StringEntry('OrderType') |
238
|
|
|
memo = StringEntry('Memo') |
239
|
|
|
receipt_info = StringEntry('ReceiptInfo') |
240
|
|
|
|
241
|
|
|
|
242
|
|
|
class SubmitMembercardUserInfoEvent(BaseCardEvent): |
243
|
|
|
__type__ = 'submit_membercard_user_info_event' |
244
|
|
|
|
245
|
|
|
|
246
|
|
|
class UnknownEvent(WeChatEvent): |
247
|
|
|
__type__ = 'unknown_event' |
248
|
|
|
|