mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 20:59:27 +01:00
Yay! Now Network.whois can retrieve information for any domain.
This commit is contained in:
parent
d2e1d80b27
commit
31c8af3fda
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
* Updated Network.whois so that it can now retrieve
|
||||||
|
information on all domains.
|
||||||
|
|
||||||
|
* Updated the Weather plugin to be retrieve weather from
|
||||||
|
either hamweather.net or cnn.com. Also added
|
||||||
|
supybot.plugins.Weather.{weatherCommand,temperatureUnit} so
|
||||||
|
that you can specify which command (Weather.cnn or
|
||||||
|
Weather.ham) to use when Weather.weather is called and in which
|
||||||
|
unit (C, F, K) to report the weather.
|
||||||
|
|
||||||
* Made standard replies (such as supybot.replies.success, etc.)
|
* Made standard replies (such as supybot.replies.success, etc.)
|
||||||
use the standard substitute (such as $nick, $who, $channel, etc.)
|
use the standard substitute (such as $nick, $who, $channel, etc.)
|
||||||
in their text.
|
in their text.
|
||||||
|
@ -71,75 +71,80 @@ class Network(callbacks.Privmsg):
|
|||||||
except socket.error:
|
except socket.error:
|
||||||
irc.reply('Host not found.')
|
irc.reply('Host not found.')
|
||||||
|
|
||||||
_tlds = sets.Set(['com', 'net', 'edu', 'org'])
|
_tlds = sets.Set(['com', 'net', 'edu'])
|
||||||
|
_registrar = ['Sponsoring Registrar', 'Registrar', 'source']
|
||||||
|
_updated = ['Last Updated On', 'Domain Last Updated Date', 'Updated Date',
|
||||||
|
'Last Modified', 'changed']
|
||||||
|
_created = ['Created On', 'Domain Registration Date', 'Creation Date']
|
||||||
|
_expires = ['Expiration Date', 'Domain Expiration Date']
|
||||||
|
_status = ['Status', 'Domain Status', 'status']
|
||||||
def whois(self, irc, msg, args):
|
def whois(self, irc, msg, args):
|
||||||
"""<domain>
|
"""<domain>
|
||||||
|
|
||||||
Returns WHOIS information on the registration of <domain>. <domain>
|
Returns WHOIS information on the registration of <domain>.
|
||||||
must be in tlds .com, .net, .edu, or .org.
|
|
||||||
"""
|
"""
|
||||||
domain = privmsgs.getArgs(args)
|
domain = privmsgs.getArgs(args)
|
||||||
usertld = domain.split('.')[-1]
|
usertld = domain.split('.')[-1]
|
||||||
if '.' not in domain or usertld not in self._tlds:
|
if '.' not in domain:
|
||||||
irc.error('<domain> must be in .com, .net, .edu, or .org.')
|
irc.error('<domain> must be in .com, .net, .edu, or .org.')
|
||||||
return
|
return
|
||||||
elif len(domain.split('.')) != 2:
|
elif len(domain.split('.')) != 2:
|
||||||
irc.error('<domain> must be a domain, not a hostname.')
|
irc.error('<domain> must be a domain, not a hostname.')
|
||||||
return
|
return
|
||||||
if usertld == 'org':
|
if usertld in self._tlds:
|
||||||
t = telnetlib.Telnet('whois.pir.org', 43)
|
server = 'rs.internic.net'
|
||||||
t.write(domain)
|
search = '=%s' % domain
|
||||||
t.write('\n')
|
|
||||||
s = t.read_all()
|
|
||||||
for line in s.splitlines():
|
|
||||||
line = line.strip()
|
|
||||||
if not line:
|
|
||||||
continue
|
|
||||||
if line.startswith('Sponsoring Registrar'):
|
|
||||||
registar = ':'.join(line.split(':')[1:])
|
|
||||||
elif line.startswith('Last Updated On'):
|
|
||||||
updated = ':'.join(line.split(':')[1:])
|
|
||||||
elif line.startswith('Created On'):
|
|
||||||
created = ':'.join(line.split(':')[1:])
|
|
||||||
elif line.startswith('Expiration Date'):
|
|
||||||
expires = ':'.join(line.split(':')[1:])
|
|
||||||
elif line.startswith('Status'):
|
|
||||||
status = ':'.join(line.split(':')[1:]).lower()
|
|
||||||
t = telnetlib.Telnet('whois.pir.org', 43)
|
|
||||||
t.write('registrar id ')
|
|
||||||
t.write(registar)
|
|
||||||
t.write('\n')
|
|
||||||
s = t.read_all()
|
|
||||||
for line in s.splitlines():
|
|
||||||
line = line.strip()
|
|
||||||
if not line:
|
|
||||||
continue
|
|
||||||
if line.startswith('Email'):
|
|
||||||
url = 'registered at '
|
|
||||||
url += line.split('@')[-1]
|
|
||||||
else:
|
else:
|
||||||
t = telnetlib.Telnet('rs.internic.net', 43)
|
server = '%s.whois-servers.net' % usertld
|
||||||
t.write('=')
|
search = domain
|
||||||
t.write(domain)
|
|
||||||
t.write('\n')
|
|
||||||
s = t.read_all()
|
|
||||||
for line in s.splitlines():
|
|
||||||
line = line.strip()
|
|
||||||
if not line:
|
|
||||||
continue
|
|
||||||
elif line.startswith('Referral'):
|
|
||||||
url = line.split()[-1]
|
|
||||||
elif line.startswith('Updated'):
|
|
||||||
updated = line.split()[-1]
|
|
||||||
elif line.startswith('Creation'):
|
|
||||||
created = line.split()[-1]
|
|
||||||
elif line.startswith('Expiration'):
|
|
||||||
expires = line.split()[-1]
|
|
||||||
elif line.startswith('Status'):
|
|
||||||
status = line.split()[-1].lower()
|
|
||||||
try:
|
try:
|
||||||
s = '%s <%s> is %s; registered %s, updated %s, expires %s.' % \
|
t = telnetlib.Telnet(server, 43)
|
||||||
(domain, url, status, created, updated, expires)
|
except socket.error, e:
|
||||||
|
irc.error(str(e))
|
||||||
|
return
|
||||||
|
t.write(search)
|
||||||
|
t.write('\n')
|
||||||
|
s = t.read_all()
|
||||||
|
(registrar, updated, created, expires, status) = ('', '', '', '', '')
|
||||||
|
for line in s.splitlines():
|
||||||
|
line = line.strip()
|
||||||
|
if not line or ':' not in line:
|
||||||
|
continue
|
||||||
|
if not registrar and any(line.startswith, self._registrar):
|
||||||
|
registrar = ':'.join(line.split(':')[1:]).strip()
|
||||||
|
elif not updated and any(line.startswith, self._updated):
|
||||||
|
s = ':'.join(line.split(':')[1:]).strip()
|
||||||
|
updated = 'updated %s' % s
|
||||||
|
elif not created and any(line.startswith, self._created):
|
||||||
|
s = ':'.join(line.split(':')[1:]).strip()
|
||||||
|
created = 'registered %s' % s
|
||||||
|
elif not expires and any(line.startswith, self._expires):
|
||||||
|
s = ':'.join(line.split(':')[1:]).strip()
|
||||||
|
expires = 'expires %s' % s
|
||||||
|
elif not status and any(line.startswith, self._status):
|
||||||
|
status = ':'.join(line.split(':')[1:]).strip().lower()
|
||||||
|
if not status:
|
||||||
|
status = 'unknown'
|
||||||
|
try:
|
||||||
|
t = telnetlib.Telnet('whois.pir.org', 43)
|
||||||
|
except socket.error, e:
|
||||||
|
irc.error(str(e))
|
||||||
|
return
|
||||||
|
t.write('registrar id ')
|
||||||
|
t.write(registrar)
|
||||||
|
t.write('\n')
|
||||||
|
s = t.read_all()
|
||||||
|
for line in s.splitlines():
|
||||||
|
line = line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
if line.startswith('Email'):
|
||||||
|
url = ' <registered at %s>' % line.split('@')[-1]
|
||||||
|
if line == 'Not a valid ID pattern':
|
||||||
|
url = ''
|
||||||
|
try:
|
||||||
|
s = '%s%s is %s; %s.' % (domain, url, status,
|
||||||
|
', '.join(filter(None, [created, updated, expires])))
|
||||||
irc.reply(s)
|
irc.reply(s)
|
||||||
except NameError, e:
|
except NameError, e:
|
||||||
irc.error('I couldn\'t find such a domain.')
|
irc.error('I couldn\'t find such a domain.')
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
from testsupport import *
|
from testsupport import *
|
||||||
|
|
||||||
if network:
|
if network:
|
||||||
class NetworkTestCase(PluginTestCase, PluginDocumentation):
|
class NetworkTestCase(PluginTestCase):
|
||||||
plugins = ['Network']
|
plugins = ['Network']
|
||||||
def testDns(self):
|
def testDns(self):
|
||||||
self.assertNotError('dns slashdot.org')
|
self.assertNotError('dns slashdot.org')
|
||||||
@ -45,6 +45,7 @@ if network:
|
|||||||
self.assertNotError('network whois kuro5hin.org')
|
self.assertNotError('network whois kuro5hin.org')
|
||||||
self.assertError('network whois www.kuro5hin.org')
|
self.assertError('network whois www.kuro5hin.org')
|
||||||
self.assertNotError('network whois microsoft.com')
|
self.assertNotError('network whois microsoft.com')
|
||||||
|
self.assertNotError('network whois goatse.cx')
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
Loading…
Reference in New Issue
Block a user