import socket import ssl def test_telegram_connection(): try: ip = "149.154.167.220" port = 443 sock = socket.create_connection((ip, port), timeout=5) context = ssl.create_default_context() with context.wrap_socket(sock, server_hostname="api.telegram.org") as ssock: print("TLS handshake successful with Telegram") except Exception as e: print("Failed:", e) test_telegram_connection()