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 handle_danmu(self, dic): cmd = dic['cmd'] # print(cmd) if cmd == 'DANMU_MSG': msg = dic['info'][1] if '-' in msg: list_word = msg.split('-') try: roomid = int(list_word[0]) raffleid = int(list_word[1]) printer.info([f'弹幕监控检测到{roomid:^9}的提督/舰长{raffleid}'], True) rafflehandler.Rafflehandler.Put2Queue( (1, roomid, raffleid), rafflehandler.handle_1_guard_raffle) Statistics.append2pushed_raffle('提督/舰长', area_id=1) except ValueError: print(msg) Printer().print_danmu(dic)
def DanMuraffle(self, dic): cmd = dic['cmd'] if cmd == 'SPECIAL_GIFT': if 'data' in dic and '39' in dic['data'] and dic['data']['39'][ 'action'] == 'start': printer.info([f'房间号{self.roomid}有节奏风暴'], True) rafflehandler.Rafflehandler.Put2Queue( (self.roomid, dic['data']['39']['id']), rafflehandler.handle_1_room_storm) Statistics.append2pushed_raffle('节奏风暴', 1) if cmd == 'GUARD_MSG': if 'buy_type' in dic and dic['buy_type'] != 1: # print(dic) 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)
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)
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)