-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtondns.py
110 lines (78 loc) · 4.22 KB
/
tondns.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# █▀▀ ▄▀█ █▀▄▀█ █▀█ █▀▄ █▀
# █▀░ █▀█ █░▀░█ █▄█ █▄▀ ▄█
# https://t.me/famods
# 🔒 Licensed under the GNU AGPLv3
# 🌐 https://www.gnu.org/licenses/agpl-3.0.html
# ---------------------------------------------------------------------------------
# Name: TonDNS
# Description: Модуль для работы с TON DNS
# meta developer: @FAmods
# meta banner: https://github.com/FajoX1/FAmods/blob/main/assets/banners/tondns.png?raw=true
# requires: aiohttp
# ---------------------------------------------------------------------------------
import logging
import aiohttp
import asyncio
from datetime import datetime
from .. import loader, utils
logger = logging.getLogger(__name__)
@loader.tds
class TonDNS(loader.Module):
"""Модуль для работы с Ton DNS"""
strings = {
"name": "TonDNS",
"waiting": "<b><emoji document_id=6334391057186293707>🕑</emoji> Собираю информацию...</b>",
"waiting_shot": "<b><emoji document_id=6334391057186293707>📸</emoji> Делаю скриншот TON DNS сайта...</b>",
"shot_ton_dns": "<b>💎 Скриншот TON DNS сайта <code>{}</code></b>",
"ton_shot_link": "https://mini.s-shot.ru/1920x1080/JPEG/1024/Z100/?{}",
}
async def client_ready(self, client, db):
self.db = db
self._client = client
@loader.command()
async def itondns(self, message):
"""Информация о TON DNS"""
address = utils.get_args_raw(message)
if not address:
return await utils.answer(message, f"<emoji document_id=5019523782004441717>❌</emoji> <b>Должно быть</b> <code>{self.get_prefix()}itondns тон_домен</code>")
await utils.answer(message, self.strings["waiting"])
async with aiohttp.ClientSession() as session:
async with session.get(f"https://tonapi.io/v2/dns/{address}") as res:
response = await res.json()
try:
response['error']
if "can't decode address" in response['error']:
return await utils.answer(message, f"<b>❌ Это не адрес кошелька!</b>")
return await utils.answer(message, f"""<b>❌ Ошибка!\n\n
<code>{response['error']}</code>
</b>""")
except:
pass
await utils.answer(message, f"""<b>
<emoji document_id=5854713299794398583>💎</emoji> Ton DNS
Имя: <code>{response['name']}</code>
Адрес: <code>{response['item']['address']}</code>
⌛️ Истекает: <i>{datetime.fromtimestamp(response['expiring_at'])}</i>
🧑💻 Владелец
Адресс: <code>{response['item']['owner']['address']}</code>
🌐 DNS адрес: <code>{response['item']['dns']}</code>
<a href="https://tonscan.org/address/{address}">Tonscan</a> • <a href="{response['item']['previews'][2]['url']}">Image</a> • <a href="https://tonscan.org/address/{address}#source">Contract</a>
</b>""")
@loader.command()
async def tonshot(self, message):
"""Скриншот TON DNS сайта"""
address = utils.get_args_raw(message)
if not address:
return await utils.answer(message, f"<emoji document_id=5019523782004441717>❌</emoji> <b>Должно быть</b> <code>.tonshot тон_домен</code>")
await utils.answer(message, self.strings["waiting_shot"])
address = address.replace("https://", "")
address = address.replace("http://", "")
ton_dns = address
address += f"-s.cam"
try:
await message.client.send_file(message.chat_id, self.strings['ton_shot_link'].format(address), caption=self.strings['shot_ton_dns'].format(ton_dns))
await message.delete()
except:
address = address.replace("-s.cam", ".run")
await message.client.send_file(message.chat_id, self.strings['ton_shot_link'].format(address), caption=self.strings['shot_ton_dns'].format(ton_dns))
await message.delete()