예제 #1
0
class ShakearoundUserShakeEvent(BaseEvent):
    event = "shakearound_user_shake"
    _chosen_beacon = BaseField("ChosenBeacon", {})
    _around_beacons = BaseField("AroundBeacons", {})

    @property
    def chosen_beacon(self):
        beacon = self._chosen_beacon
        if not beacon:
            return {}
        return {
            "uuid": beacon["Uuid"],
            "major": beacon["Major"],
            "minor": beacon["Minor"],
            "distance": float(beacon["Distance"]),
        }

    @property
    def around_beacons(self):
        beacons = self._around_beacons
        if not beacons:
            return []

        ret = []
        for beacon in beacons["AroundBeacon"]:
            ret.append({
                "uuid": beacon["Uuid"],
                "major": beacon["Major"],
                "minor": beacon["Minor"],
                "distance": float(beacon["Distance"]),
            })
        return ret
예제 #2
0
class BatchJobResultEvent(events.BaseEvent):
    """
    异步任务完成事件

    详情请参阅
    https://work.weixin.qq.com/api/doc/90000/90135/90240#%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E5%AE%8C%E6%88%90%E4%BA%8B%E4%BB%B6%E6%8E%A8%E9%80%81
    """

    event = "batch_job_result"
    batch_job = BaseField("BatchJob")

    @property
    def job_id(self):
        return self.batch_job["JobId"]

    @property
    def job_type(self):
        return self.batch_job["JobType"]

    @property
    def err_code(self):
        return self.batch_job["ErrCode"]

    @property
    def err_msg(self):
        return self.batch_job["ErrMsg"]
예제 #3
0
class LocationSelectEvent(BaseEvent):
    """
    弹出地理位置选择器的事件

    详情请参阅
    https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Custom_Menu_Push_Events.html
    """

    event = "location_select"
    key = StringField("EventKey")
    location_info = BaseField("SendLocationInfo", {})

    @property
    def location_x(self):
        return self.location_info["Location_X"]

    @property
    def location_y(self):
        return self.location_info["Location_Y"]

    @property
    def location(self):
        return self.location_x, self.location_y

    @property
    def scale(self):
        return self.location_info["Scale"]

    @property
    def label(self):
        return self.location_info["Label"]

    @property
    def poiname(self):
        return self.location_info["Poiname"]
예제 #4
0
class SubscribeMsgSentEvent(BaseEvent):
    """
    发送订阅通知事件

    详情请参阅
    https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html
    """

    subscribes_info = BaseField("SubscribeMsgSentEvent", {})

    @property
    def subscribes(self) -> List[Dict]:
        """
        返回值参考:
        [
          {
            "TemplateId": "VRR0UEO9VJOLs0MHlU0OilqX6MVFDwH3_3gz3Oc0NIc",
            "MsgID": "1700827132819554304",
            "ErrorCode": "0",
            "ErrorStatus": "success",
          },
        ]
        """
        subscribes = self.subscribes_info["List"]
        if not isinstance(subscribes, list):
            subscribes = [subscribes]
        return subscribes
예제 #5
0
class SubscribeMsgChangeEvent(BaseEvent):
    """
    用户管理订阅通知事件

    详情请参阅
    https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html
    """

    subscribes_info = BaseField("SubscribeMsgChangeEvent", {})

    @property
    def subscribes(self) -> List[Dict]:
        """
        返回值参考:
        [
          {
            "TemplateId": "VRR0UEO9VJOLs0MHlU0OilqX6MVFDwH3_3gz3Oc0NIc",
            "SubscribeStatusString": "accept",
          },
          {
            "TemplateId": "9nLIlbOQZC5Y89AZteFEux3WCXRRRG5Wfzkpssu4bLI",
            "SubscribeStatusString": "reject",
          },
        ]
        """
        subscribes = self.subscribes_info["List"]
        if not isinstance(subscribes, list):
            subscribes = [subscribes]
        return subscribes
예제 #6
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"]
예제 #7
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"]
예제 #8
0
class BaseScanCodeEvent(BaseEvent):
    key = StringField("EventKey")
    scan_code_info = BaseField("ScanCodeInfo", {})

    @property
    def scan_type(self):
        return self.scan_code_info["ScanType"]

    @property
    def scan_result(self):
        return self.scan_code_info["ScanResult"]
예제 #9
0
class BasePictureEvent(BaseEvent):
    key = StringField("EventKey")
    pictures_info = BaseField("SendPicsInfo", {})

    @property
    def count(self):
        return int(self.pictures_info["Count"])

    @property
    def pictures(self):
        if self.pictures_info["PicList"]:
            items = self.pictures_info["PicList"]["item"]
            if self.count > 1:
                return items
            return [items]
        return []