aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2019-01-31 09:27:02 +0100
committernsensfel <SpamShield0@noot-noot.org>2019-01-31 09:27:02 +0100
commit550604f7de4ee54715ec22f08a7fc65b19747e3f (patch)
treef571c03aff8942a622aede67cef3809914e8ab7f
parente882093b9e70c97b07e98a5d920cd136a82d298c (diff)
downloaddiscord-550604f7de4ee54715ec22f08a7fc65b19747e3f.zip
discord-550604f7de4ee54715ec22f08a7fc65b19747e3f.tar.bz2
Maybe adds a last resort timeout function.
-rw-r--r--jh-discord.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/jh-discord.py b/jh-discord.py
index fc85733..9b0d059 100644
--- a/jh-discord.py
+++ b/jh-discord.py
@@ -2,7 +2,9 @@ import discord
import asyncio
import argparse
import socket
-
+import threading
+import sys
+import time
################################################################################
## MAIN ########################################################################
@@ -104,4 +106,13 @@ async def on_message(message):
if (len(result) > 0):
await client.send_message(message.channel, result)
+def exit_if_disconnected ():
+ while True:
+ time.sleep(61)
+
+ if ((not client.is_logged_in) or client.is_closed):
+ print("Timed out.")
+ sys.exit()
+
+threading.Thread(target=exit_if_disconnected).start()
client.run(args.token)