Пример #1
0
async def DanMuraffle(area_id, connect_roomid, dic):
    cmd = dic['cmd']
    
    if cmd == 'PREPARING':
        printer.info([f'{area_id}号弹幕监控房间下播({connect_roomid})'], True)
        return False
    elif cmd == 'SYS_GIFT':
        if 'giftId' in dic:
            if str(dic['giftId']) in bilibili.get_giftids_raffle_keys():
                
                text1 = dic['real_roomid']
                text2 = dic['url']
                giftId = dic['giftId']
                printer.info(["检测到房间{:^9}的{}活动抽奖".format(text1, bilibili.get_giftids_raffle(str(giftId)))], True)
                rafflehandler.Rafflehandler.Put2Queue((giftId, text1, text2), rafflehandler.handle_1_room_activity)
                Statistics.append2pushed_raffle('活动', area_id=area_id)
                        
            elif dic['giftId'] == 39:
                printer.info(["节奏风暴"], True)
                temp = await bilibili.get_giftlist_of_storm(dic)
                check = len(temp['data'])
                if check != 0 and temp['data']['hasJoin'] != 1:
                    id = temp['data']['id']
                    json_response1 = await bilibili.get_gift_of_storm(id)
                    print(json_response1)
                else:
                    printer.info([dic, "请联系开发者"])
            else:
                text1 = dic['real_roomid']
                text2 = dic['url']
                printer.info([dic, "请联系开发者"])
                try:
                    giftId = dic['giftId']
                    printer.info(["检测到房间{:^9}的{}活动抽奖".format(text1, bilibili.get_giftids_raffle(str(giftId)))], True)
                    rafflehandler.Rafflehandler.Put2Queue((giftId, text1, text2), rafflehandler.handle_1_room_activity)
                    Statistics.append2pushed_raffle('活动', area_id=area_id)
                            
                except:
                    printer.info([dic, "请联系开发者"])
                
        else:
            printer.info(['普通送礼提示', dic['msg_text']])
        return
    elif cmd == 'SYS_MSG':
        if 'real_roomid' in dic:
            real_roomid = dic['real_roomid']
            type_text = (dic['msg'].split(':?')[-1]).split(',')[0].replace('一个', '')
            printer.info([f'{area_id}号弹幕监控检测到{real_roomid:^9}的{type_text}'], True)
            rafflehandler.Rafflehandler.Put2Queue((real_roomid,), rafflehandler.handle_1_room_TV)
            Statistics.append2pushed_raffle(type_text, area_id=area_id)
            
    elif cmd == 'GUARD_MSG':
        a = re.compile(r"(?<=在主播 )\S+(?= 的直播间开通了总督)")
        res = re.search(a, dic['msg'])
        if res is not None:
            name = str(res.group())
            printer.info([f'{area_id}号弹幕监控检测到{name:^9}的总督'], True)
            rafflehandler.Rafflehandler.Put2Queue((((name,), utils.find_live_user_roomid),), rafflehandler.handle_1_room_captain)
            Statistics.append2pushed_raffle('总督', area_id=area_id)
    def DanMuraffle(self, dic):
        cmd = dic['cmd']

        if cmd == 'PREPARING':
            printer.info([f'{self.area_id}号弹幕监控房间下播({self.roomid})'], True)
            return False
        elif cmd == 'SYS_GIFT':
            if 'giftId' in dic:
                if dic['giftId'] == 39:
                    printer.info(["节奏风暴"], True)
                    roomid = dic['roomid']
                    rafflehandler.Rafflehandler.Put2Queue(
                        (roomid, ), rafflehandler.handle_1_room_storm)
                    Statistics.append2pushed_raffle('节奏风暴',
                                                    area_id=self.area_id)
                else:
                    text1 = dic['real_roomid']
                    text2 = dic['url']
                    printer.info([dic, "请联系开发者"])
                    try:
                        giftId = dic['giftId']
                        printer.info([
                            "检测到房间{:^9}的{}活动抽奖".format(
                                text1, bilibili.get_giftids_raffle(
                                    str(giftId)))
                        ], True)
                        rafflehandler.Rafflehandler.Put2Queue(
                            (giftId, text1, text2),
                            rafflehandler.handle_1_room_activity)
                        Statistics.append2pushed_raffle('活动',
                                                        area_id=self.area_id)

                    except:
                        printer.info([dic, "请联系开发者"])

            else:
                printer.info(['普通送礼提示', dic['msg_text']])
            return
        elif cmd == 'SYS_MSG':
            if 'real_roomid' in dic:
                real_roomid = dic['real_roomid']
                type_text = (dic['msg'].split(':?')[-1]).split(',')[0][2:]
                printer.info(
                    [f'{self.area_id}号弹幕监控检测到{real_roomid:^9}的{type_text}'],
                    True)
                rafflehandler.Rafflehandler.Put2Queue(
                    (real_roomid, ), rafflehandler.handle_1_room_TV)
                rafflehandler.Rafflehandler.Put2Queue(
                    (real_roomid, ), rafflehandler.handle_1_room_activity)
                Statistics.append2pushed_raffle(type_text,
                                                area_id=self.area_id)

        elif cmd == 'GUARD_MSG':
            a = re.compile(r"(?<=在主播 )\S+(?= 的直播间开通了总督)")
            print(dic)
            res = re.search(a, dic['msg'])
            if res is not None:
                name = str(res.group())
                printer.info([f'{self.area_id}号弹幕监控检测到{name:^9}的总督'], True)
                rafflehandler.Rafflehandler.Put2Queue(
                    (((name, ), utils.find_live_user_roomid), ),
                    rafflehandler.handle_1_room_captain)
                Statistics.append2pushed_raffle('总督', area_id=self.area_id)
Пример #3
0
    def handle_danmu(self, dic):
        cmd = dic['cmd']

        if cmd == 'PREPARING':
            printer.info([f'{self.area_id}号弹幕监控房间下播({self.roomid})'], True)
            return False
        elif cmd == 'SYS_GIFT':
            if 'giftId' in dic:
                if dic['giftId'] == 39:
                    printer.info(["节奏风暴"], True)
                    roomid = dic['roomid']
                    rafflehandler.Rafflehandler.Put2Queue(
                        (roomid, ), rafflehandler.handle_1_room_storm)
                    Statistics.append2pushed_raffle('节奏风暴',
                                                    area_id=self.area_id)
                else:
                    text1 = dic['real_roomid']
                    text2 = dic['url']
                    printer.info([dic, "请联系开发者"])
                    try:
                        giftId = dic['giftId']
                        printer.info([
                            "检测到房间{:^9}的{}活动抽奖".format(
                                text1, bilibili.get_giftids_raffle(
                                    str(giftId)))
                        ], True)
                        rafflehandler.Rafflehandler.Put2Queue(
                            (giftId, text1, text2),
                            rafflehandler.handle_1_room_activity)
                        Statistics.append2pushed_raffle('活动',
                                                        area_id=self.area_id)

                    except:
                        printer.info([dic, "请联系开发者"])

            else:
                printer.info(['普通送礼提示', dic['msg_text']])
            return
        elif cmd == 'SYS_MSG':
            if 'real_roomid' in dic:
                real_roomid = dic['real_roomid']
                type_text = (dic['msg'].split(':?')[-1]).split(',')[0][2:]
                printer.info(
                    [f'{self.area_id}号弹幕监控检测到{real_roomid:^9}的{type_text}'],
                    True)
                rafflehandler.Rafflehandler.Put2Queue(
                    (real_roomid, ), rafflehandler.handle_1_room_TV)
                rafflehandler.Rafflehandler.Put2Queue(
                    (real_roomid, ), rafflehandler.handle_1_room_activity)
                Statistics.append2pushed_raffle(type_text,
                                                area_id=self.area_id)

        elif cmd == 'GUARD_MSG':
            if 'buy_type' in dic and dic['buy_type'] == 1:
                roomid = dic['roomid']
                printer.info([f'{self.area_id}号弹幕监控检测到{roomid:^9}的总督'], True)
                rafflehandler.Rafflehandler.Put2Queue(
                    (roomid, ), rafflehandler.handle_1_room_guard)
                Statistics.append2pushed_raffle('总督', area_id=self.area_id)
            if 'buy_type' in dic and dic['buy_type'] != 1:
                print(dic)
                # roomid = dic['roomid']
                printer.info([f'{self.area_id}号弹幕监控检测到{self.roomid:^9}的提督/舰长'],
                             True)
                rafflehandler.Rafflehandler.Put2Queue(
                    (self.roomid, ), rafflehandler.handle_1_room_guard)
                Statistics.append2pushed_raffle('提督/舰长', area_id=self.area_id)
Пример #4
0
async def parseDanMu(messages):
    # await bilibili.request_send_danmu_msg_andriod('hbhnukunkunk', 6149819)

    try:
        dic = json.loads(messages)
    except:
        return
    cmd = dic['cmd']

    if cmd == 'DANMU_MSG':
        # print(dic)
        Printer().printlist_append(['danmu', '弹幕', 'user', dic])
        return
    if cmd == 'SYS_GIFT':
        if 'giftId' in dic.keys():
            if str(dic['giftId']) in bilibili.get_giftids_raffle_keys():

                text1 = dic['real_roomid']
                text2 = dic['url']
                giftId = dic['giftId']
                Printer().printlist_append([
                    'join_lottery', '', 'user', "检测到房间{:^9}的{}活动抽奖".format(
                        text1, bilibili.get_giftids_raffle(str(giftId)))
                ], True)
                rafflehandler.Rafflehandler.Put2Queue(
                    rafflehandler.handle_1_room_activity,
                    (giftId, text1, text2))
                Statistics.append2pushed_activitylist()

            elif dic['giftId'] == 39:
                Printer().printlist_append(
                    ['join_lottery', '', 'user', "节奏风暴"])
                temp = await bilibili.get_giftlist_of_storm(dic)
                check = len(temp['data'])
                if check != 0 and temp['data']['hasJoin'] != 1:
                    id = temp['data']['id']
                    json_response1 = await bilibili.get_gift_of_storm(id)
                    print(json_response1)
                else:
                    Printer().printlist_append(
                        ['join_lottery', '', 'debug', [dic, "请联系开发者"]])
            else:
                text1 = dic['real_roomid']
                text2 = dic['url']
                Printer().printlist_append(
                    ['join_lottery', '', 'debug', [dic, "请联系开发者"]])
                try:
                    giftId = dic['giftId']
                    Printer().printlist_append([
                        'join_lottery', '', 'user', "检测到房间{:^9}的{}活动抽奖".format(
                            text1, bilibili.get_giftids_raffle(str(giftId)))
                    ], True)
                    rafflehandler.Rafflehandler.Put2Queue(
                        rafflehandler.handle_1_room_activity,
                        (giftId, text1, text2))
                    Statistics.append2pushed_activitylist()

                except:
                    pass

        else:
            Printer().printlist_append([
                'join_lottery', '普通送礼提示', 'user', ['普通送礼提示', dic['msg_text']]
            ])
        return
    if cmd == 'SYS_MSG':
        if dic.get('real_roomid', None) is None:
            Printer().printlist_append(
                ['join_lottery', '系统公告', 'user', dic['msg']])
        else:
            try:
                TV_url = dic['url']
                real_roomid = dic['real_roomid']
                Printer().printlist_append([
                    'join_lottery', '小电视', 'user',
                    f'检测到房间{real_roomid:^9}的小电视抽奖'
                ], True)
                # url = "https://api.live.bilibili.com/AppSmallTV/index?access_key=&actionKey=appkey&appkey=1d8b6e7d45233436&build=5230003&device=android&mobi_app=android&platform=android&roomid=939654&ts=1521734039&sign=4f85e1d3ce0e1a3acd46fcf9ca3cbeed"
                rafflehandler.Rafflehandler.Put2Queue(
                    rafflehandler.handle_1_room_TV, (real_roomid, ))
                Statistics.append2pushed_TVlist()

            except:
                print('请联系开发者', dic)
    if cmd == 'GUARD_MSG':
        print(dic)
        a = re.compile(r"(?<=在主播 )\S+(?= 的直播间开通了总督)")
        res = re.search(a, dic['msg'])
        if res is not None:
            print(str(res.group()))
            roomid = utils.find_live_user_roomid(str(res.group()))
            Printer().printlist_append(
                ['join_lottery', '', 'user', f'检测到房间{roomid:^9}开通总督'], True)
            rafflehandler.Rafflehandler.Put2Queue(
                rafflehandler.handle_1_room_captain, (roomid, ))
            Statistics.append2pushed_captainlist()
        else:
            a = re.compile(r"(.*)欢迎(.*)总督(.*)登船")
            res = re.search(a, dic['msg'])
            if res is not None:
                print('请反馈')
                roomid = ConfigLoader(
                ).dic_user['other_control']['default_monitor_roomid']
                Printer().printlist_append(
                    ['join_lottery', '', 'user', f'检测到房间{roomid:^9}开通总督'],
                    True)
                rafflehandler.Rafflehandler.Put2Queue(
                    rafflehandler.handle_1_room_captain, (roomid, ))
                Statistics.append2pushed_captainlist()