added more information in whois

This commit is contained in:
kiriharu 2021-01-04 01:52:50 +03:00
parent 2ad86d1bb6
commit 2b4ce947bd

View File

@ -16,13 +16,48 @@ no_domain_text = """
def create_whois_message(domain: str) -> str:
domain_info = whois.whois(domain)
if domain_info.get("domain_name") is None:
domain_name = domain_info.get("domain_name")
if domain_name is None:
return no_domain_text
message = f"\n📝Имя: {domain_info.get('domain_name')}" \
f"\n👤Регистратор: {domain_info.get('registrar')}" \
f"\n📅Дата создания: {domain_info.get('creation_date')}" \
f"\n📅Дата окончания: {domain_info.get('expiration_date')}" \
f"\n📌NS: {' '.join(domain_info.get('name_servers'))}"
if isinstance(domain_name, list):
domain_name = domain_name[0]
message = f"\n📝 Информация о домене {domain_name.lower()}:" \
f"\n\n👤 Регистратор: {domain_info.get('registrar')}" \
if creation_date := domain_info.get('creation_date'):
if isinstance(creation_date, list):
creation_date = creation_date[0]
message += f"\n📅 Дата создания: {creation_date}"
if expiration_date := domain_info.get('expiration_date'):
if isinstance(expiration_date, list):
expiration_date = expiration_date[0]
message += f"\n📅 Дата окончания:: {expiration_date}\n"
if address := domain_info.get("address"):
message += f"\n📖 Адрес: {address}"
if city := domain_info.get("city"):
message += f"\n🏘 Город: {city}"
if country := domain_info.get("country"):
message += f"\n🏳️ Страна: {country}"
if name := domain_info.get("name"):
message += f"\n💬 Имя: {name}"
if org := domain_info.get("org"):
message += f"\n💼 Организация: {org}"
if zipcode := domain_info.get("zipcode"):
message += f"\n🖥 Zipcode: {zipcode}"
if emails := domain_info.get("emails"):
message += "\n✉️ Почта: \n" + str.join("\n", [f" * <code>{email}</code>" for email in emails])
if name_servers := domain_info.get('name_servers'):
message += "\n\n📌 NS: \n" + str.join("\n", [f" * <code>{ns}</code>" for ns in
list(set(map(str.lower, name_servers)))])
if dnssec := domain_info.get("dnssec"):
message += f"\n🔐 DNSSec: {dnssec}"
return message
@ -32,4 +67,5 @@ async def whois_cmd(msg: Message):
return await msg.answer(no_domain_text)
if len(args) >= 2:
host = args[1]
await msg.answer(create_whois_message(host))
await msg.bot.send_chat_action(msg.chat.id, 'typing')
await msg.answer(create_whois_message(host), parse_mode='html')