1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

KeyboardInterrupts might work

This commit is contained in:
Steffo 2018-08-16 19:43:42 +02:00
parent 96acfe2874
commit 31e6b5354d
2 changed files with 9 additions and 4 deletions

View file

@ -356,9 +356,6 @@ class RoyalDiscordBot(discord.Client):
if msg == "get cv":
discord_members = list(self.main_guild.members)
connection.send(discord_members)
elif msg == "stop":
await self.logout()
exit(0)
elif msg.startswith("!"):
data = msg.split(" ")
if data[0] not in self.commands:
@ -740,7 +737,12 @@ def process(users_connection=None):
logging.info("Logging in...")
loop.run_until_complete(bot.login(config["Discord"]["bot_token"], bot=True))
logging.info("Connecting...")
loop.run_until_complete(bot.connect())
try:
loop.run_until_complete(bot.connect())
except KeyboardInterrupt:
logging.info("Now stopping...")
loop.run_until_complete(self.logout())
exit(0)
if __name__ == "__main__":

View file

@ -635,6 +635,9 @@ def process(arg_discord_connection):
logging.warning("Timed out, restarting in 1 minute.")
time.sleep(60)
logging.info("Now restarting...")
except KeyboardInterrupt:
logging.info("Now stopping...")
break
if __name__ == "__main__":