Example #1
0
    async def work(user, dyn_raffle_status: DynRaffleStatus):
        if dyn_raffle_status.lottery_time - utils.curr_time() < 15:
            user.info(f'动态{dyn_raffle_status.dyn_id}马上或已经开奖,放弃参与')
        async with user.repost_del_lock:
            if dyn_raffle_status.feed_limit:  # 关注
                await DynRaffleJoinTask.follow_raffle_organizer(
                    user, dyn_raffle_status.uid)

            # 创建动态并提交数据库
            if await DynRaffleJoinTask.repost_dyn_raffle(
                    user, dyn_raffle_status.dyn_id, dyn_raffle_status.at_num):
                user.info(f'转发参与动态{dyn_raffle_status.dyn_id}成功')
                for i in range(5):  # 经常不能及时刷新
                    await asyncio.sleep(3)
                    dyn_id = await DynRaffleJoinTask.fetch_reposted_dynid(
                        user, user.dict_bili['uid'], dyn_raffle_status.dyn_id)
                    if dyn_id is not None:
                        user.info(
                            f'查找转发动态{dyn_raffle_status.dyn_id}生成{dyn_id}')
                        dyn_raffle_joined = DynRaffleJoined(
                            dyn_id=dyn_id,
                            orig_dynid=dyn_raffle_status.dyn_id,
                            uid=user.dict_bili['uid'])
                        print(dyn_raffle_joined)
                        dyn_raffle_sql.insert_dynraffle_joined_table(
                            dyn_raffle_joined)
                        return
                user.warn(f'查找转发动态{dyn_raffle_status.dyn_id}生成失败')
            else:
                user.warn(f'转发参与动态{dyn_raffle_status.dyn_id}失败')
            return
Example #2
0
    async def join(user, dyn_raffle_status: DynRaffleStatus):
        async with user.repost_del_lock:
            if dyn_raffle_status.feed_limit:  # 关注
                await DynRaffleHandlerTask.follow_raffle_organizer(
                    user, dyn_raffle_status.uid)

            # 创建动态并提交数据库
            if await DynRaffleHandlerTask.repost_dyn_raffle(
                    user, dyn_raffle_status.dyn_id, dyn_raffle_status.at_num):
                user.info([f'转发参与动态{dyn_raffle_status.dyn_id}成功'], True)
                for i in range(5):  # 经常不能及时刷新
                    await asyncio.sleep(3)
                    dyn_id = await DynRaffleHandlerTask.fetch_reposted_dynid(
                        user, user.dict_bili['uid'], dyn_raffle_status.dyn_id)
                    if dyn_id is not None:
                        user.info(
                            [f'查找转发动态{dyn_raffle_status.dyn_id}生成{dyn_id}'],
                            True)
                        dyn_raffle_joined = DynRaffleJoined(
                            dyn_id=dyn_id,
                            orig_dynid=dyn_raffle_status.dyn_id,
                            uid=user.dict_bili['uid'])
                        print(dyn_raffle_joined)
                        dyn_raffle_sql.insert_dynraffle_joined_table(
                            dyn_raffle_joined)
                        return
                user.warn(f'查找转发动态{dyn_raffle_status.dyn_id}生成失败')
            else:
                user.warn(f'转发参与动态{dyn_raffle_status.dyn_id}失败')
            return