mirror of
				https://github.com/catspace-dev/unicheckbot.git
				synced 2025-10-31 15:37:31 +03:00 
			
		
		
		
	whois command
This commit is contained in:
		
							parent
							
								
									28386de8fa
								
							
						
					
					
						commit
						2ad86d1bb6
					
				|  | @ -9,6 +9,7 @@ python = "^3.8" | |||
| aiogram = "^2.11.2" | ||||
| core = {path = "../core"} | ||||
| httpx = "^0.16.1" | ||||
| python-whois = "^0.7.3" | ||||
| 
 | ||||
| [tool.poetry.dev-dependencies] | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,8 +2,10 @@ from aiogram import Dispatcher | |||
| 
 | ||||
| from .start import start_cmd | ||||
| from .web import web_cmd | ||||
| from .whois import whois_cmd | ||||
| 
 | ||||
| 
 | ||||
| def setup(dp: Dispatcher): | ||||
|     dp.register_message_handler(start_cmd, commands=['start']) | ||||
|     dp.register_message_handler(web_cmd, commands=['web', 'http']) | ||||
|     dp.register_message_handler(whois_cmd, commands=['whois']) | ||||
|  |  | |||
							
								
								
									
										35
									
								
								apps/tgbot/tgbot/handlers/default/whois.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								apps/tgbot/tgbot/handlers/default/whois.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,35 @@ | |||
| from aiogram.types import Message | ||||
| import whois | ||||
| 
 | ||||
| whois_help_message = """ | ||||
| ❓ Вернёт информацию о домене. | ||||
| 
 | ||||
|  Использование: `/whois <домен>` | ||||
| """ | ||||
| 
 | ||||
| no_domain_text = """ | ||||
| ❗Не указан домен или указан неверный/несуществующий домен. | ||||
| 
 | ||||
| Напишите /whois чтобы посмотреть справку. | ||||
| """ | ||||
| 
 | ||||
| 
 | ||||
| def create_whois_message(domain: str) -> str: | ||||
|     domain_info = whois.whois(domain) | ||||
|     if domain_info.get("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'))}" | ||||
|     return message | ||||
| 
 | ||||
| 
 | ||||
| async def whois_cmd(msg: Message): | ||||
|     args = msg.text.split(" ") | ||||
|     if len(args) == 1: | ||||
|         return await msg.answer(no_domain_text) | ||||
|     if len(args) >= 2: | ||||
|         host = args[1] | ||||
|         await msg.answer(create_whois_message(host)) | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user