Exemplo n.º 1
0
async def handle_1_TV_raffle_black(num, real_roomid, raffleid, raffle_type):
    # print('ffffffffffggggdgdfddf')
    for i in range(50):
        json_response2 = await bilibili.get_gift_of_TV_app(
            real_roomid, raffleid, raffle_type)
        code = json_response2['code']
        if not code:
            break
        elif code == -403:
            return True
        elif code == -405:
            print('没抢到。。。。。')
            printer.warn(raffleid)
            return False
        elif code != -401 and code != -403:
            # print('00', json_response2)
            pass
        # await asyncio.sleep()
    code = json_response2['code']
    if code:
        await asyncio.sleep(5)
        return
    data = json_response2['data']
    Statistics.append_to_TVlist(raffleid, real_roomid)
    Statistics.add_to_result(data['gift_name'], int(data['gift_num']))
    printer.info([f'参与了房间{real_roomid:^9}的道具抽奖'], True)
    # printer.info([f'# 道具抽奖状态: {json_response2["msg"]}'])
    printer.info([
        f'# 房间{real_roomid:^9}网页端活动抽奖结果: {data["gift_name"]}X{data["gift_num"]}'
    ])
    return True
Exemplo n.º 2
0
async def handle_1_TV_raffle(num, real_roomid, raffleid, raffle_type):
    while True:
        json_response2 = await bilibili.get_gift_of_TV_app(
            real_roomid, raffleid, raffle_type)
        code = json_response2['code']
        if not code:
            break
        elif code == -403:
            return True
        elif code == -405:
            print('没抢到。。。。。')
            printer.warn(raffleid)
            return False
        elif code == 400:
            print(json_response2)
            tasklist = []
            for i in range(60):
                task = asyncio.ensure_future(
                    handle_1_TV_raffle_black(num, real_roomid, raffleid,
                                             raffle_type))
                tasklist.append(task)
            await asyncio.wait(tasklist, return_when=asyncio.FIRST_COMPLETED)
            return
        elif code != -401 and code != -403:
            pass

    data = json_response2['data']
    Statistics.append_to_TVlist(raffleid, real_roomid)
    Statistics.add_to_result(data['gift_name'], int(data['gift_num']))
    printer.info([f'参与了房间{real_roomid:^9}的道具抽奖'], True)
    # printer.info([f'# 道具抽奖状态: {json_response2["msg"]}'])
    printer.info([
        f'# 房间{real_roomid:^9}网页端活动抽奖结果: {data["gift_name"]}X{data["gift_num"]}'
    ])
    return True
Exemplo n.º 3
0
async def handle_1_TV_raffle(num, real_roomid, raffleid):
    # print('参与')
    await asyncio.sleep(random.uniform(0.5, min(30, num * 1.3)))
    json_response2 = await bilibili.get_gift_of_TV(real_roomid, raffleid)
    Printer().printlist_append(
        ['join_lottery', '小电视', 'user', f'参与了房间{real_roomid:^9}的小电视抽奖'], True)
    Printer().printlist_append([
        'join_lottery', '小电视', 'user', "# 小电视道具抽奖状态: ", json_response2['msg']
    ])
    # -400不存在
    # -500繁忙
    if not json_response2['code']:
        Statistics.append_to_TVlist(raffleid, real_roomid)
        return True
    elif json_response2['code'] == -500:
        print('# -500繁忙,稍后重试')
        return False
    else:
        print(json_response2)
        return True