Skip to content

Commit

Permalink
函数好好干活 别想着搞新闻
Browse files Browse the repository at this point in the history
print尽量要返回后执行
  • Loading branch information
yjqiang committed Apr 12, 2019
1 parent 3408e86 commit d4f626f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 5 additions & 4 deletions danmu/bili_danmu_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ async def _prepare_client(self):
self._room_id = await notifier.exec_func(
-1, UtilsTask.get_room_by_area,
self._area_id, self._room_id)
print(f'{self._area_id}号数据连接选择房间({self._room_id})')

def handle_danmu(self, data: dict):
cmd = data['cmd']

if cmd == 'PREPARING':
print(f'{self._area_id}号弹幕监控房间下播({self._room_id})')
print(f'{self._area_id}号数据连接房间下播({self._room_id})')
return False

elif cmd == 'NOTICE_MSG':
Expand All @@ -82,19 +83,19 @@ def handle_danmu(self, data: dict):
raffle_num = 1
raffle_name = str_gift
broadcast = msg_common.split('广播')[0]
print(f'{self._area_id}号弹幕监控检测到{real_roomid:^9}{raffle_name}')
print(f'{self._area_id}号数据连接检测到{real_roomid:^9}{raffle_name}')
raffle_handler.push2queue(TvRaffleHandlerTask, real_roomid)
broadcast_type = 0 if broadcast == '全区' else 1
bili_statistics.add2pushed_raffles(raffle_name, broadcast_type, raffle_num)
elif msg_type == 3:
raffle_name = msg_common.split('开通了')[-1][:2]
print(f'{self._area_id}号弹幕监控检测到{real_roomid:^9}{raffle_name}')
print(f'{self._area_id}号数据连接检测到{real_roomid:^9}{raffle_name}')
raffle_handler.push2queue(GuardRaffleHandlerTask, real_roomid)
broadcast_type = 0 if raffle_name == '总督' else 2
bili_statistics.add2pushed_raffles(raffle_name, broadcast_type)
elif msg_type == 6:
raffle_name = '二十倍节奏风暴'
print(f'{self._area_id}号弹幕监控检测到{real_roomid:^9}{raffle_name}')
print(f'{self._area_id}号数据连接检测到{real_roomid:^9}{raffle_name}')
# raffle_handler.push2queue(StormRaffleHandlerTask, real_roomid)
bili_statistics.add2pushed_raffles(raffle_name)
return True
3 changes: 0 additions & 3 deletions tasks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,17 @@ async def get_room_by_area(user, area_id, room_id=None):
# None/0 都不行
if room_id is not None and room_id:
if await UtilsTask.is_ok_as_monitor(user, room_id, area_id):
printer.infos([f'{area_id}号弹幕监控选择房间({room_id})'])
return room_id
if area_id == 1:
room_id = 23058
if await UtilsTask.is_ok_as_monitor(user, room_id, area_id):
printer.infos([f'{area_id}号弹幕监控选择房间({room_id})'])
return room_id

while True:
json_rsp = await user.req_s(UtilsReq.get_rooms_by_area, user, area_id)
data = json_rsp['data']
room_id = random.choice(data)['roomid']
if await UtilsTask.is_ok_as_monitor(user, room_id, area_id):
printer.infos([f'{area_id}号弹幕监控选择房间({room_id})'])
return room_id

@staticmethod
Expand Down

0 comments on commit d4f626f

Please sign in to comment.