Skip to content

Commit

Permalink
Internet: Use socket directly instead of telnetlib
Browse files Browse the repository at this point in the history
We don't actually need telnetlib here; and it will be removed in
Python 3.11
  • Loading branch information
progval committed May 5, 2024
1 parent 802ab3d commit 9767f2d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions plugins/Internet/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

import time
import socket
import telnetlib

import supybot.conf as conf
import supybot.utils as utils
Expand Down Expand Up @@ -158,14 +157,14 @@ def whois(self, irc, msg, args, domain):
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()
Expand Down

0 comments on commit 9767f2d

Please sign in to comment.