Esempio n. 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")
Esempio n. 2
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")
Esempio n. 3
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")
Esempio n. 4
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)
Esempio n. 5
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)})"
Esempio n. 6
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")
Esempio n. 7
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
Esempio n. 8
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")
Esempio n. 9
0
class OpenApprovalChangeEvent(events.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"]
Esempio n. 10
0
class PicWeChatEvent(events.PicWeChatEvent):
    """
    弹出微信相册发图器事件

    详情请参阅
    https://work.weixin.qq.com/api/doc/90000/90135/90240#%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"
Esempio n. 11
0
class PicSysPhotoEvent(events.PicSysPhotoEvent):
    """
    弹出系统拍照发图事件

    详情请参阅
    https://work.weixin.qq.com/api/doc/90000/90135/90240#%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"
Esempio n. 12
0
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")
Esempio n. 13
0
class LocationSelectEvent(events.LocationSelectEvent):
    """
    弹出地理位置选择器事件

    详情请参阅
    https://work.weixin.qq.com/api/doc/90000/90135/90240#%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"
Esempio n. 14
0
class PicPhotoOrAlbumEvent(events.PicPhotoOrAlbumEvent):
    """
    弹出拍照或相册发图事件

    详情请参阅
    https://work.weixin.qq.com/api/doc/90000/90135/90240#%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"
Esempio n. 15
0
class ScanCodeWaitMsgEvent(events.ScanCodeWaitMsgEvent):
    """
    扫码推事件且弹出“消息接收中”提示框的事件

    详情请参阅
    https://work.weixin.qq.com/api/doc/90000/90135/90240#%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"
Esempio n. 16
0
class EnterAgentEvent(events.BaseEvent):
    """
    用户进入应用的事件推送

    详情请参阅
    https://work.weixin.qq.com/api/doc/90000/90135/90240#%E8%BF%9B%E5%85%A5%E5%BA%94%E7%94%A8
    """

    agent = IntegerField("AgentID", 0)
    event = "enter_agent"
Esempio n. 17
0
class LocationEvent(events.LocationEvent):
    """
    上报地理位置事件

    详情请参阅
    https://work.weixin.qq.com/api/doc/90000/90135/90240#%E4%B8%8A%E6%8A%A5%E5%9C%B0%E7%90%86%E4%BD%8D%E7%BD%AE
    """

    agent = IntegerField("AgentID", 0)
    event = "location"
Esempio n. 18
0
class ScanCodePushEvent(events.ScanCodePushEvent):
    """
    扫码推事件的事件

    详情请参阅
    https://work.weixin.qq.com/api/doc/90000/90135/90240#%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"
Esempio n. 19
0
class ClickEvent(events.ClickEvent):
    """
    点击菜单拉取消息事件

    详情请参阅
    https://work.weixin.qq.com/api/doc/90000/90135/90240#%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"
Esempio n. 20
0
class ViewEvent(events.ViewEvent):
    """
    点击菜单跳转链接事件

    详情请参阅
    https://work.weixin.qq.com/api/doc/90000/90135/90240#%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"
Esempio n. 21
0
class UnsubscribeEvent(events.UnsubscribeEvent):
    """
    成员取消关注事件

    详情请参阅
    https://work.weixin.qq.com/api/doc/90000/90135/90240#%E6%88%90%E5%91%98%E5%85%B3%E6%B3%A8%E5%8F%8A%E5%8F%96%E6%B6%88%E5%85%B3%E6%B3%A8%E4%BA%8B%E4%BB%B6
    """

    agent = IntegerField("AgentID", 0)
    event = "unsubscribe"
Esempio n. 22
0
class SysApprovalChangeEvent(events.BaseEvent):
    """
    系统审批状态通知事件

    详情请参阅
    https://work.weixin.qq.com/api/doc/90000/90135/91815
    """

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

    @property
    def sp_no(self):
        return self.approval_info["SpNo"]

    @property
    def sp_name(self):
        return self.approval_info["SpName"]

    @property
    def template_id(self):
        return self.approval_info["TemplateId"]

    @property
    def sp_status(self):
        return self.approval_info["SpStatus"]

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

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

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

    @property
    def sp_record(self):
        return self.approval_info["SpRecord"]

    @property
    def notifyer(self):
        return self.approval_info["Notifyer"]

    @property
    def comments(self):
        return self.approval_info["Comments"]

    @property
    def statu_change_event(self):
        return self.approval_info["StatuChangeEvent"]
Esempio n. 23
0
class TemplateSendJobFinishEvent(BaseEvent):
    """
    模板消息任务完成事件

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

    id = IntegerField("MsgID")
    event = "templatesendjobfinish"
    status = StringField("Status")
Esempio n. 24
0
class TaskCardClickEvent(events.BaseEvent):
    """
    任务卡片事件推送

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

    event = "taskcard_click"
    event_key = StringField("EventKey")
    agent = IntegerField("AgentID", 0)
    task_id = StringField("TaskId")
Esempio n. 25
0
class TaskCardReply(replies.BaseReply):
    """被动回复格式-任务卡更新消息
    接口详细文档:
    https://work.weixin.qq.com/api/doc/90000/90135/90241#%E4%BB%BB%E5%8A%A1%E5%8D%A1%E7%89%87%E6%9B%B4%E6%96%B0%E6%B6%88%E6%81%AF
    """

    agent = IntegerField("AgentID", 0)
    type = "update_taskcard"
    taskcard = TaskCardField("")

    @property
    def replace_name(self):
        return self.taskcard

    @replace_name.setter
    def replace_name(self, value):
        self.taskcard = value
Esempio n. 26
0
class BaseReply(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"""
        nodes = []
        msg_type = f"<MsgType><![CDATA[{self.type}]]></MsgType>"
        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 f"<xml>\n{data}\n</xml>"

    def __str__(self):
        return self.render()
Esempio n. 27
0
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")
Esempio n. 28
0
class LinkMessage(messages.LinkMessage):
    agent = IntegerField("AgentID", 0)
    pic_url = StringField("PicUrl")
Esempio n. 29
0
class LocationMessage(messages.LocationMessage):
    agent = IntegerField("AgentID", 0)
Esempio n. 30
0
class VideoMessage(messages.VideoMessage):
    agent = IntegerField("AgentID", 0)