class WiFiConnectedEvent(BaseEvent): event = 'wificconnected' connect_time = IntegerField('ConnectTime') expire_time = IntegerField('ExpireTime') vendor_id = StringField('VendorId') shop_id = StringField('PlaceId') bssid = StringField('DeviceNo')
class UpdateMemberCard(BaseEvent): """ 会员卡内容更新事件 详情请参阅 https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Coupons_Vouchers_and_Cards_Event_Push_Messages.html#9 """ event = 'update_member_card' card_id = StringField('CardId') code = StringField('UserCardCode') modify_bonus = IntegerField('ModifyBonus') modify_balance = IntegerField('ModifyBalance')
class UserGiftingCardEvent(BaseEvent): """ 转赠事件推送 详情请参阅 https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Coupons_Vouchers_and_Cards_Event_Push_Messages.html#3 """ event = 'user_gifting_card' card_id = StringField('CardId') code = StringField('UserCardCode') is_return_back = IntegerField('IsReturnBack') friend = StringField('FriendUserName') is_chat_room = IntegerField('IsChatRoom')
class UserPayFromPayCell(BaseEvent): """ 卡券买单事件推送 详情请参阅 https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Coupons_Vouchers_and_Cards_Event_Push_Messages.html#6 """ event = 'user_pay_from_pay_cell' card_id = StringField('CardId') code = StringField('UserCardCode') trans_id = StringField('TransId') location_id = IntegerField('LocationId') fee = IntegerField('Fee') original_fee = IntegerField('OriginalFee')
class MassSendJobFinishEvent(BaseEvent): """ 群发消息任务完成事件 详情请参阅 https://mp.weixin.qq.com/wiki?id=mp1481187827_i0l21 """ id = IntegerField('MsgID', 0) event = 'masssendjobfinish' status = StringField('Status') total_count = IntegerField('TotalCount', 0) filter_count = IntegerField('FilterCount', 0) sent_count = IntegerField('SentCount', 0) error_count = IntegerField('ErrorCount', 0)
class UserScanProductEvent(BaseEvent): """ 打开商品主页事件 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1455872179 """ event = 'user_scan_product' standard = StringField('KeyStandard') key = StringField('KeyStr') country = StringField('Country') province = StringField('Province') city = StringField('City') sex = IntegerField('Sex') scene = IntegerField('Scene')
class ScanCodeWaitMsgEvent(events.ScanCodeWaitMsgEvent): """ 扫码推事件且弹出“消息接收中”提示框的事件 详情请参阅 http://qydev.weixin.qq.com/wiki/index.php?title=接收事件#.E6.89.AB.E7.A0.81.E6.8E.A8.E4.BA.8B.E4.BB.B6.E4.B8.94.E5.BC.B9.E5.87.BA.E2.80.9C.E6.B6.88.E6.81.AF.E6.8E.A5.E6.94.B6.E4.B8.AD.E2.80.9D.E6.8F.90.E7.A4.BA.E6.A1.86.E7.9A.84.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81 """ agent = IntegerField('AgentID', 0) event = 'scancode_waitmsg'
class ScanCodePushEvent(events.ScanCodePushEvent): """ 扫码推事件的事件 详情请参阅 http://qydev.weixin.qq.com/wiki/index.php?title=接收事件#.E6.89.AB.E7.A0.81.E6.8E.A8.E4.BA.8B.E4.BB.B6.E7.9A.84.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81 """ agent = IntegerField('AgentID', 0) event = 'scancode_push'
class LocationEvent(events.LocationEvent): """ 上报地理位置事件 详情请参阅 http://qydev.weixin.qq.com/wiki/index.php?title=接收事件#.E4.B8.8A.E6.8A.A5.E5.9C.B0.E7.90.86.E4.BD.8D.E7.BD.AE.E4.BA.8B.E4.BB.B6 """ agent = IntegerField('AgentID', 0) event = 'location'
class ViewEvent(events.ViewEvent): """ 点击菜单跳转链接事件 详情请参阅 http://qydev.weixin.qq.com/wiki/index.php?title=接收事件#.E7.82.B9.E5.87.BB.E8.8F.9C.E5.8D.95.E8.B7.B3.E8.BD.AC.E9.93.BE.E6.8E.A5.E7.9A.84.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81 """ agent = IntegerField('AgentID', 0) event = 'view'
class ClickEvent(events.ClickEvent): """ 点击菜单拉取消息事件 详情请参阅 http://qydev.weixin.qq.com/wiki/index.php?title=接收事件#.E7.82.B9.E5.87.BB.E8.8F.9C.E5.8D.95.E6.8B.89.E5.8F.96.E6.B6.88.E6.81.AF.E7.9A.84.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81 """ agent = IntegerField('AgentID', 0) event = 'click'
class UnsubscribeEvent(events.UnsubscribeEvent): """ 成员取消关注事件 详情请参阅 https://qydev.weixin.qq.com/wiki/index.php?title=接收事件#.E6.88.90.E5.91.98.E5.85.B3.E6.B3.A8.2F.E5.8F.96.E6.B6.88.E5.85.B3.E6.B3.A8.E4.BA.8B.E4.BB.B6 """ agent = IntegerField('AgentID', 0) event = 'unsubscribe'
class EnterAgentEvent(events.BaseEvent): """ 用户进入应用的事件推送 详情请参阅 http://qydev.weixin.qq.com/wiki/index.php?title=接收事件#.E6.88.90.E5.91.98.E8.BF.9B.E5.85.A5.E5.BA.94.E7.94.A8.E7.9A.84.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81 """ agent = IntegerField('AgentID', 0) event = 'enter_agent'
class LocationSelectEvent(events.LocationSelectEvent): """ 弹出地理位置选择器事件 详情请参阅 http://qydev.weixin.qq.com/wiki/index.php?title=接收事件#.E5.BC.B9.E5.87.BA.E5.9C.B0.E7.90.86.E4.BD.8D.E7.BD.AE.E9.80.89.E6.8B.A9.E5.99.A8.E7.9A.84.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81 """ agent = IntegerField('AgentID', 0) event = 'location_select'
class PicWeChatEvent(events.PicWeChatEvent): """ 弹出微信相册发图器事件 详情请参阅 http://qydev.weixin.qq.com/wiki/index.php?title=接收事件#.E5.BC.B9.E5.87.BA.E5.BE.AE.E4.BF.A1.E7.9B.B8.E5.86.8C.E5.8F.91.E5.9B.BE.E5.99.A8.E7.9A.84.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81 """ agent = IntegerField('AgentID', 0) event = 'pic_weixin'
class PicPhotoOrAlbumEvent(events.PicPhotoOrAlbumEvent): """ 弹出拍照或相册发图事件 详情请参阅 http://qydev.weixin.qq.com/wiki/index.php?title=接收事件#.E5.BC.B9.E5.87.BA.E6.8B.8D.E7.85.A7.E6.88.96.E8.80.85.E7.9B.B8.E5.86.8C.E5.8F.91.E5.9B.BE.E7.9A.84.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81 """ agent = IntegerField('AgentID', 0) event = 'pic_photo_or_album'
class PicSysPhotoEvent(events.PicSysPhotoEvent): """ 弹出系统拍照发图事件 详情请参阅 http://qydev.weixin.qq.com/wiki/index.php?title=接收事件#.E5.BC.B9.E5.87.BA.E7.B3.BB.E7.BB.9F.E6.8B.8D.E7.85.A7.E5.8F.91.E5.9B.BE.E7.9A.84.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81 """ agent = IntegerField('AgentID', 0) event = 'pic_sysphoto'
class UserGetCardEvent(BaseEvent): """ 领取事件推送 详情请参阅 https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Coupons_Vouchers_and_Cards_Event_Push_Messages.html#2 """ event = 'user_get_card' card_id = StringField('CardId') is_given_by_friend = IntegerField('IsGiveByFriend') friend = StringField('FriendUserName') code = StringField('UserCardCode') old_code = StringField('OldUserCardCode') outer_id = StringField('OuterId') outer_str = StringField('OuterStr') is_restore_member_card = IntegerField('IsRestoreMemberCard') is_recommend_by_friend = IntegerField('IsRecommendByFriend') union_id = StringField('UnionId')
class BaseMessage(six.with_metaclass(MessageMetaClass)): """Base class for all messages and events""" type = 'unknown' id = IntegerField('MsgId', 0) source = StringField('FromUserName') target = StringField('ToUserName') create_time = DateTimeField('CreateTime') time = IntegerField('CreateTime') def __init__(self, message): self._data = message def __repr__(self): _repr = "{klass}({msg})".format(klass=self.__class__.__name__, msg=repr(self._data)) if six.PY2: return to_binary(_repr) else: return to_text(_repr)
class TemplateSendJobFinishEvent(BaseEvent): """ 模板消息任务完成事件 详情请参阅 https://mp.weixin.qq.com/wiki?id=mp1433751277 """ id = IntegerField('MsgID') event = 'templatesendjobfinish' status = StringField('Status')
class BaseReply(six.with_metaclass(MessageMetaClass)): """Base class for all replies""" source = StringField('FromUserName') target = StringField('ToUserName') time = IntegerField('CreateTime', time.time()) type = 'unknown' def __init__(self, **kwargs): self._data = {} message = kwargs.pop('message', None) if message and isinstance(message, BaseMessage): if 'source' not in kwargs: kwargs['source'] = message.target if 'target' not in kwargs: kwargs['target'] = message.source if hasattr(message, 'agent') and 'agent' not in kwargs: kwargs['agent'] = message.agent if 'time' not in kwargs: kwargs['time'] = time.time() for name, value in kwargs.items(): field = self._fields.get(name) if field: self._data[field.name] = value else: setattr(self, name, value) def render(self): """Render reply from Python object to XML string""" tpl = '<xml>\n{data}\n</xml>' nodes = [] msg_type = '<MsgType><![CDATA[{msg_type}]]></MsgType>'.format( msg_type=self.type) nodes.append(msg_type) for name, field in self._fields.items(): value = getattr(self, name, field.default) node_xml = field.to_xml(value) nodes.append(node_xml) data = '\n'.join(nodes) return tpl.format(data=data) def __str__(self): if six.PY2: return to_binary(self.render()) else: return to_text(self.render())
class CardPayOrderEvent(BaseEvent): """ 券点流水详情事件 详情请参阅 https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Coupons_Vouchers_and_Cards_Event_Push_Messages.html#11 """ event = 'card_pay_order' order_id = IntegerField('OrderId') status = StringField('Status') create_order_time = IntegerField('CreateOrderTime') pay_finish_time = IntegerField('PayFinishTime') description = StringField('Desc') free_coin_count = IntegerField('FreeCoinCount') pay_coin_count = IntegerField('PayCoinCount') refund_free_coin_count = IntegerField('RefundFreeCoinCount') refund_pay_coin_count = IntegerField('RefundPayCoinCount') order_type = StringField('OrderType') memo = StringField('Memo') receipt_info = StringField('ReceiptInfo')
class DeviceUnsubscribeStatusEvent(BaseEvent): event = 'device_unsubscribe_status' device_type = StringField('DeviceType') device_id = StringField('DeviceID') open_id = StringField('OpenID') op_type = IntegerField('OpType')
class MerchantOrderEvent(BaseEvent): event = 'merchant_order' order_id = StringField('OrderId') order_status = IntegerField('OrderStatus') product_id = StringField('ProductId') sku_info = StringField('SkuInfo')
class VideoReply(replies.VideoReply): agent = IntegerField('AgentID', 0)
class ArticlesReply(replies.ArticlesReply): agent = IntegerField('AgentID', 0)
class VoiceReply(replies.VoiceReply): agent = IntegerField('AgentID', 0)
class HardwareReply(BaseReply): type = 'hardware' func_flag = IntegerField('FuncFlag', 0) hardware = HardwareField('HardWare')
class DeviceStatusReply(BaseReply): type = 'device_status' device_type = StringField('DeviceType') device_id = StringField('DeviceID') status = IntegerField('DeviceStatus')
class ImageReply(replies.ImageReply): agent = IntegerField('AgentID', 0)