Exemplo n.º 1
0
async def init_monitors():
    yjmonitor_tcp_addr = other_control['yjmonitor_tcp_addr']
    yjmonitor_tcp_key = other_control['yjmonitor_tcp_key']

    raffle_danmu_areaids = area_ids
    printer_danmu_roomid = default_roomid
    yjmonitor_tcp_addr = yjmonitor_tcp_addr
    yjmonitor_tcp_key = yjmonitor_tcp_key
    session = aiohttp.ClientSession()

    _danmu_monitors = []

    for area_id in raffle_danmu_areaids:
        monitor = DanmuRaffleMonitor(room_id=0,
                                     area_id=area_id,
                                     session=session)
        _danmu_monitors.append(monitor)

    if yjmonitor_tcp_key:
        monitor = TcpYjMonitorClient(key=yjmonitor_tcp_key,
                                     url=yjmonitor_tcp_addr,
                                     area_id=0)
        _danmu_monitors.append(monitor)

    _danmu_printer = DanmuPrinter(room_id=printer_danmu_roomid,
                                  area_id=-1,
                                  session=session)

    if other_control['substance_raffle']:
        _danmu_monitors.append(SubstanceRaffleMonitor())
    if other_control['dyn_raffle']:
        _danmu_monitors.append(
            DynRaffleMonitor(should_join_immediately=other_control[
                'join_dyn_raffle_at_once']))
    return _danmu_printer, _danmu_monitors
Exemplo n.º 2
0
    async def init_monitors():
        session = aiohttp.ClientSession()
        monitors_ = []
        # 弹幕打印功能
        danmu_printer_ = DanmuPrinter(room_id=default_roomid,
                                      area_id=-1,
                                      session=session)

        # 弹幕抽奖监控
        for area_id in area_ids:
            monitor = DanmuRaffleMonitor(room_id=0,
                                         area_id=area_id,
                                         session=session)
            monitors_.append(monitor)

        # yjmonitor 弹幕监控
        yjmonitor_tcp_addr = other_control['yjmonitor_tcp_addr']
        yjmonitor_tcp_key = other_control['yjmonitor_tcp_key']
        if yjmonitor_tcp_key:
            monitor = TcpYjMonitorClient(key=yjmonitor_tcp_key,
                                         url=yjmonitor_tcp_addr,
                                         area_id=0)
            monitors_.append(monitor)
        if other_control['substance_raffle']:
            monitors_.append(SubstanceRaffleMonitor())
        if other_control['dyn_raffle']:
            monitors_.append(
                DynRaffleMonitor(should_join_immediately=other_control[
                    'join_dyn_raffle_at_once']))
        return danmu_printer_, monitors_
Exemplo n.º 3
0
if sys.platform != 'linux' or signal.getsignal(
        signal.SIGHUP) == signal.SIG_DFL:
    console_thread = threading.Thread(
        target=Biliconsole(loop, default_roomid, printer_danmu).cmdloop)
    console_thread.start()
else:
    console_thread = None

notifier.exec_task(-2, HeartBeatTask, 0, delay_range=(0, 5))
notifier.exec_task(-2, RecvHeartGiftTask, 0, delay_range=(0, 5))
notifier.exec_task(-2, OpenSilverBoxTask, 0, delay_range=(0, 5))
notifier.exec_task(-2, RecvDailyBagTask, 0, delay_range=(0, 5))
notifier.exec_task(-2, SignTask, 0, delay_range=(0, 5))
notifier.exec_task(-2, WatchTvTask, 0, delay_range=(0, 5))
notifier.exec_task(-2, SignFansGroupsTask, 0, delay_range=(0, 5))
notifier.exec_task(-2, SendGiftTask, 0, delay_range=(0, 5))
notifier.exec_task(-2, ExchangeSilverCoinTask, 0, delay_range=(0, 5))
notifier.exec_task(-2, JudgeCaseTask, 0, delay_range=(0, 5))
notifier.exec_task(-2, BiliMainTask, 0, delay_range=(0, 5))

other_tasks = [
    SubstanceRaffleMonitor().run(),
    # DynRaffleMonitor(should_join_immediately=True).run(),
]
if other_tasks:
    loop.run_until_complete(asyncio.wait(other_tasks))
loop.run_forever()
if console_thread is not None:
    console_thread.join()