From e18332efde702bf37d5b29d056f7c94de8279a5d Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 5 May 2024 20:36:58 +0200 Subject: [PATCH] Internet: Use socket directly instead of telnetlib We don't actually need telnetlib here; and it will be removed in Python 3.11 --- plugins/Internet/plugin.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/plugins/Internet/plugin.py b/plugins/Internet/plugin.py index d9993db1b..410e6d9a3 100644 --- a/plugins/Internet/plugin.py +++ b/plugins/Internet/plugin.py @@ -31,7 +31,6 @@ import time import socket -import telnetlib import supybot.conf as conf import supybot.utils as utils @@ -158,14 +157,14 @@ class Internet(callbacks.Plugin): if not status: status = 'unknown' try: - t = telnetlib.Telnet('whois.iana.org', 43) + sock = socket.create_connection(('whois.iana.org', 43)) except socket.error as e: irc.error(str(e)) return - t.write(b'registrar ') - t.write(registrar.split('(')[0].strip().encode('ascii')) - t.write(b'\n') - s = t.read_all() + sock.sendall(b'registrar ') + sock.sendall(registrar.split('(')[0].strip().encode('ascii')) + sock.sendall(b'\n') + s = sock.recv(100000) url = '' for line in s.splitlines(): line = line.decode('ascii').strip()