diff --git a/bert.py b/bert.py index fd9ddae..bdbcd3c 100755 --- a/bert.py +++ b/bert.py @@ -72,7 +72,7 @@ def connect(host, port): global irc print("Connecting to "+host+":"+str(port)) context = ssl.create_default_context() - with socket.create_connection((host, port)) as sock: + with socket.create_connection((host, port), timeout=180) as sock: irc = context.wrap_socket(sock, server_hostname=host) @@ -141,6 +141,9 @@ def me(chan, msg): def getData(): raw = irc.recv(4096) + if not raw: + print("Connection lost!") + sys.exit(0) try: data = raw.decode("UTF-8") except: