Пример #1
0
class WiFiConnectedEvent(BaseEvent):
    event = 'wificconnected'
    connect_time = IntegerField('ConnectTime')
    expire_time = IntegerField('ExpireTime')
    vendor_id = StringField('VendorId')
    shop_id = StringField('PlaceId')
    bssid = StringField('DeviceNo')
Пример #2
0
class WiFiConnectedEvent(BaseEvent):
    event = "wificconnected"
    connect_time = IntegerField("ConnectTime")
    expire_time = IntegerField("ExpireTime")
    vendor_id = StringField("VendorId")
    shop_id = StringField("PlaceId")
    bssid = StringField("DeviceNo")
Пример #3
0
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')
    time = IntegerField('CreateTime', 0)

    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)

    @property
    def create_time(self):
        """消息创建时间 ``datetime.datetime`` 类型
        """
        tz = timezone('Asia/Shanghai')
        created = datetime.fromtimestamp(self.time, tz)
        return created
Пример #4
0
    def test_integer_field_to_xml(self):
        from wechatpy.fields import IntegerField

        name = 'Content'
        value = 0
        expected = '<{name}>{value}</{name}>'.format(name=name, value=value)

        field = IntegerField(name)
        self.assertEqual(expected, field.to_xml(value))
Пример #5
0
    def test_integer_field_to_xml(self):
        from wechatpy.fields import IntegerField

        name = "Content"
        value = 0
        expected = "<{name}>{value}</{name}>".format(name=name, value=value)

        field = IntegerField(name)
        self.assertEqual(expected, field.to_xml(value))
Пример #6
0
    def test_integer_field_to_xml(self):
        from wechatpy.fields import IntegerField

        name = "Content"
        value = 0
        expected = f"<{name}>{value}</{name}>"

        field = IntegerField(name)
        self.assertEqual(expected, field.to_xml(value))
Пример #7
0
class MassSendJobFinishEvent(BaseEvent):
    """
    群发消息任务完成事件
    详情请参阅
    http://mp.weixin.qq.com/wiki/15/5380a4e6f02f2ffdc7981a8ed7a40753.html
    """
    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)
Пример #8
0
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')
Пример #9
0
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')
Пример #10
0
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)
Пример #11
0
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')
Пример #12
0
class UserScanProductEvent(BaseEvent):
    """
    打开商品主页事件

    详情请参考
    http://mp.weixin.qq.com/wiki/15/f4109a5e44b4bfbc7eb1337eb739f3e3.html
    """
    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')
Пример #13
0
class BaseMessage(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):
        return f"{self.__class__.__name__}({repr(self._data)})"
Пример #14
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')
Пример #15
0
class MassSendJobFinishEvent(BaseEvent):
    """
    群发消息任务完成事件

    详情请参阅
    https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Batch_Sends_and_Originality_Checks.html#7
    """

    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)
Пример #16
0
class PicSysPhotoEvent(events.PicSysPhotoEvent):
    """
    弹出系统拍照发图事件
    详情请参阅
    http://qydev.weixin.qq.com/wiki/index.php?title=接受事件
    """
    agent = IntegerField('AgentID', 0)
Пример #17
0
class BaseMessage(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))
        return _repr
Пример #18
0
class ScanCodePushEvent(events.ScanCodePushEvent):
    """
    扫码推事件的事件
    详情请参阅
    http://qydev.weixin.qq.com/wiki/index.php?title=接受事件
    """
    agent = IntegerField('AgentID', 0)
Пример #19
0
class LocationEvent(events.LocationEvent):
    """
    上报地理位置事件
    详情请参阅
    http://qydev.weixin.qq.com/wiki/index.php?title=接受事件
    """
    agent = IntegerField('AgentID', 0)
Пример #20
0
class ViewEvent(events.ViewEvent):
    """
    点击菜单跳转链接事件
    详情请参阅
    http://qydev.weixin.qq.com/wiki/index.php?title=接受事件
    """
    agent = IntegerField('AgentID', 0)
Пример #21
0
class ClickEvent(events.ClickEvent):
    """
    点击菜单拉取消息事件
    详情请参阅
    http://qydev.weixin.qq.com/wiki/index.php?title=接受事件
    """
    agent = IntegerField('AgentID', 0)
Пример #22
0
class UnsubscribeEvent(events.UnsubscribeEvent):
    """
    成员取消关注事件
    详情请参阅
    http://qydev.weixin.qq.com/wiki/index.php?title=接受事件
    """
    agent = IntegerField('AgentID', 0)
Пример #23
0
class PicPhotoOrAlbumEvent(events.PicPhotoOrAlbumEvent):
    """
    弹出拍照或相册发图事件
    详情请参阅
    http://qydev.weixin.qq.com/wiki/index.php?title=接受事件
    """
    agent = IntegerField('AgentID', 0)
Пример #24
0
class ScanCodeWaitMsgEvent(events.ScanCodeWaitMsgEvent):
    """
    扫码推事件且弹出“消息接收中”提示框的事件
    详情请参阅
    http://qydev.weixin.qq.com/wiki/index.php?title=接受事件
    """
    agent = IntegerField('AgentID', 0)
Пример #25
0
class PicWeChatEvent(events.PicWeChatEvent):
    """
    弹出微信相册发图器事件
    详情请参阅
    http://qydev.weixin.qq.com/wiki/index.php?title=接受事件
    """
    agent = IntegerField('AgentID', 0)
Пример #26
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")
Пример #27
0
class WxaMediaCheckEvent(BaseEvent):
    """
    异步检测结果通知事件
    详情请参考
    https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/sec-check/security.mediaCheckAsync.html
    """

    event = "wxa_media_check"
    is_risky = IntegerField("isrisky")  # 检测结果,0:暂未检测到风险,1:风险
    extra_info_json = StringField("extra_info_json")  # 附加信息,默认为空
    trace_id = StringField("trace_id")  # 任务 id
    status_code = IntegerField("status_code")  # 默认为:0,4294966288(-1008)为链接无法下载

    @property
    def is_valid(self):
        return self.is_risky == 0 and self.status_code == 0
Пример #28
0
class OpenApprovalChangeEvent(BaseEvent):
    """
    审批状态通知事件

    详情请参阅
    https://work.weixin.qq.com/api/doc/90000/90135/90240#%E5%AE%A1%E6%89%B9%E7%8A%B6%E6%80%81%E9%80%9A%E7%9F%A5%E4%BA%8B%E4%BB%B6
    """

    event = "open_approval_change"
    agent = IntegerField("AgentID", 0)
    approval_info = BaseField("ApprovalInfo")

    @property
    def third_no(self):
        return self.approval_info["ThirdNo"]

    @property
    def open_sp_name(self):
        return self.approval_info["OpenSpName"]

    @property
    def open_template_id(self):
        return self.approval_info["OpenTemplateId"]

    @property
    def open_sp_status(self):
        return self.approval_info["OpenSpStatus"]

    @property
    def apply_time(self):
        return self.approval_info["ApplyTime"]

    @property
    def apply_user_name(self):
        return self.approval_info["ApplyUserName"]

    @property
    def apply_user_id(self):
        return self.approval_info["ApplyUserId"]

    @property
    def apply_user_party(self):
        return self.approval_info["ApplyUserParty"]

    @property
    def apply_user_image(self):
        return self.approval_info["ApplyUserImage"]

    @property
    def approval_nodes(self):
        return self.approval_info["ApprovalNodes"]

    @property
    def notify_nodes(self):
        return self.approval_info["NotifyNodes"]

    @property
    def approver_step(self):
        return self.approval_info["approverstep"]
Пример #29
0
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'
Пример #30
0
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'
Пример #31
0
class EnterAgentEvent(events.BaseEvent):
    """
    用户进入应用的事件推送
    详情请参阅
    http://qydev.weixin.qq.com/wiki/index.php?title=接受事件
    """
    agent = IntegerField('AgentID', 0)
    event = 'enter_agent'