Exemplo n.º 1
0
    def do_qzone_activity(
        self,
        actid,
        api,
        ctx,
        ruleid,
        query="",
        act_name="",
        gameid="",
        area="",
        partition="",
        roleid="",
        countid="",
        pretty=False,
        print_res=True,
    ):
        url = self.urls.qzone_activity.format(
            api=api,
            g_tk=self.g_tk,
            rand=random.random(),
        )
        if self.roleinfo is not None:
            area = area or self.roleinfo.serviceID
            partition = partition or self.roleinfo.serviceID
            roleid = roleid or self.roleinfo.roleCode

        raw_data = self.urls.qzone_activity_raw_data.format(
            actid=actid,
            ruleid=ruleid,
            area=area,
            partition=partition,
            roleid=roleid,
            query=query,
            act_name=act_name,
            gameid=gameid,
            uin=uin2qq(self.lr.uin),
            countid=countid,
        )

        def request_fn():
            return requests.post(
                url,
                raw_data,
                headers=self.headers,
                timeout=self.djc_helper.common_cfg.http_timeout)

        res = try_request(request_fn, self.djc_helper.common_cfg.retry)
        logger.debug(f"{raw_data}")
        return process_result(ctx, res, pretty, print_res)
Exemplo n.º 2
0
    def do_ark_lottery(self,
                       api,
                       ctx,
                       ruleid,
                       query="",
                       act_name="",
                       gameid="",
                       area="",
                       partition="",
                       roleid="",
                       pretty=False,
                       print_res=True):
        url = self.urls.ark_lottery.format(
            api=api,
            g_tk=self.g_tk,
            rand=random.random(),
        )
        if self.roleinfo is not None:
            area = area or self.roleinfo.serviceID
            partition = partition or self.roleinfo.serviceID
            roleid = roleid or self.roleinfo.roleCode

        raw_data = self.urls.ark_lottery_raw_data.format(
            actid=3886,
            ruleid=ruleid,
            area=area,
            partition=partition,
            roleid=roleid,
            query=query,
            act_name=act_name,
            gameid=gameid,
            uin=uin2qq(self.lr.uin),
        )

        request_fn = lambda: requests.post(url,
                                           raw_data,
                                           headers=self.headers,
                                           timeout=self.djc_helper.common_cfg.
                                           http_timeout)
        res = try_request(request_fn, self.djc_helper.common_cfg.retry)
        return process_result(ctx, res, pretty, print_res)