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": if msg == "get cv":
discord_members = list(self.main_guild.members) discord_members = list(self.main_guild.members)
connection.send(discord_members) connection.send(discord_members)
elif msg == "stop":
await self.logout()
exit(0)
elif msg.startswith("!"): elif msg.startswith("!"):
data = msg.split(" ") data = msg.split(" ")
if data[0] not in self.commands: if data[0] not in self.commands:
@ -740,7 +737,12 @@ def process(users_connection=None):
logging.info("Logging in...") logging.info("Logging in...")
loop.run_until_complete(bot.login(config["Discord"]["bot_token"], bot=True)) loop.run_until_complete(bot.login(config["Discord"]["bot_token"], bot=True))
logging.info("Connecting...") 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__": if __name__ == "__main__":

View file

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