From f01e1b292ae23e0d208bb14759d12da3fbaf2d44 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 5 May 2019 17:45:57 +0200 Subject: [PATCH] Possible fix for the bot not running on Linux? --- royalnet/network/royalnetserver.py | 2 ++ royalnet/royalgames.py | 9 ++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/royalnet/network/royalnetserver.py b/royalnet/network/royalnetserver.py index effae004..c61166d4 100644 --- a/royalnet/network/royalnetserver.py +++ b/royalnet/network/royalnetserver.py @@ -126,3 +126,5 @@ class RoyalnetServer: log.debug(f"Starting main server loop for __master__ on ws://{self.address}:{self.port}") # noinspection PyAsyncCall self._loop.create_task(self.serve()) + # Just to be sure it has started on Linux + await asyncio.sleep(0.5) diff --git a/royalnet/royalgames.py b/royalnet/royalgames.py index 6b57f58f..d98ab179 100644 --- a/royalnet/royalgames.py +++ b/royalnet/royalgames.py @@ -15,16 +15,18 @@ log = logging.root stream_handler = logging.StreamHandler() stream_handler.formatter = logging.Formatter("{asctime}\t{name}\t{levelname}\t{message}", style="{") log.addHandler(stream_handler) -log.setLevel(logging.INFO) +log.setLevel(logging.WARNING) commands = [PingCommand, ShipCommand, SmecdsCommand, ColorCommand, CiaoruoziCommand, DebugCreateCommand, SyncCommand, AuthorCommand, DiarioCommand, RageCommand, DateparserCommand, ReminderCommand, KvactiveCommand, KvCommand, KvrollCommand, VideoinfoCommand, SummonCommand, PlayCommand, SkipCommand, PlaymodeCommand, VideochannelCommand] -address, port = "localhost", 1234 +address, port = "127.0.0.1", 1234 master = RoyalnetServer(address, port, "sas") +loop.run_until_complete(master.start()) + ds_bot = DiscordBot(discord_config=DiscordConfig(os.environ["DS_AK"]), royalnet_config=RoyalnetConfig(f"ws://{address}:{port}", "sas"), database_config=DatabaseConfig(os.environ["DB_PATH"], Royal, Discord, "discord_id"), @@ -37,9 +39,6 @@ tg_bot = TelegramBot(telegram_config=TelegramConfig(os.environ["TG_AK"]), commands=commands, error_command=ErrorHandlerCommand, missing_command=MissingCommand) -print(tg_bot.botfather_command_string) -loop.run_until_complete(master.start()) loop.create_task(tg_bot.run()) loop.create_task(ds_bot.run()) -print("Starting loop...") loop.run_forever()