|
|
@ -37,22 +37,30 @@ def main():
|
|
|
|
|
|
|
|
|
|
|
|
commands = Commands(config, commands_logger)
|
|
|
|
commands = Commands(config, commands_logger)
|
|
|
|
|
|
|
|
|
|
|
|
discord_client = DiscordClient(config, discord_logger, commands)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def run_twitch_client():
|
|
|
|
async def run_twitch_client():
|
|
|
|
twitch_client = TwitchClient(config, twitch_logger, commands)
|
|
|
|
twitch_client = TwitchClient(config, twitch_logger, commands)
|
|
|
|
twitch_client.connect_()
|
|
|
|
twitch_client.connect_()
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
|
|
|
|
try:
|
|
|
|
twitch_client.process_data()
|
|
|
|
twitch_client.process_data()
|
|
|
|
await asyncio.sleep(TIMEOUT)
|
|
|
|
await asyncio.sleep(TIMEOUT)
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
twitch_logger.info('Exception', exc_info=e)
|
|
|
|
|
|
|
|
|
|
|
|
asyncio.ensure_future(run_twitch_client())
|
|
|
|
async def run_discord_client():
|
|
|
|
|
|
|
|
discord_client = DiscordClient(config, discord_logger, commands)
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
await discord_client.start_()
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
discord_logger.info('Exception', exc_info=e)
|
|
|
|
|
|
|
|
await discord_client.logout()
|
|
|
|
|
|
|
|
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
loop.run_until_complete(discord_client.start_())
|
|
|
|
asyncio.ensure_future(run_twitch_client())
|
|
|
|
except:
|
|
|
|
asyncio.ensure_future(run_discord_client())
|
|
|
|
loop.run_until_complete(discord_client.logout())
|
|
|
|
loop.run_forever()
|
|
|
|
finally:
|
|
|
|
finally:
|
|
|
|
loop.close()
|
|
|
|
loop.close()
|
|
|
|
|
|
|
|
|
|
|
|