diff --git a/bert.py b/bert.py index b04d748..fd9ddae 100755 --- a/bert.py +++ b/bert.py @@ -38,10 +38,8 @@ y = "\x038" r = "\x034" g = "\x033" -context = ssl.create_default_context() -with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as sock: - irc = context.wrap_socket(sock, server_hostname=host) - +# global variable for the socket, see connect() +irc = None # Currency API def get_exchange(): @@ -71,8 +69,11 @@ def safeexit(): def connect(host, port): + global irc print("Connecting to "+host+":"+str(port)) - irc.connect((host, port)) + context = ssl.create_default_context() + with socket.create_connection((host, port)) as sock: + irc = context.wrap_socket(sock, server_hostname=host) def sendRaw(data):