# █▀▀ ▄▀█   █▀▄▀█ █▀█ █▀▄ █▀ # █▀░ █▀█   █░▀░█ █▄█ █▄▀ ▄█ # https://t.me/famods # 🔒 Licensed under the GNU AGPLv3 # 🌐 https://www.gnu.org/licenses/agpl-3.0.html # --------------------------------------------------------------------------------- # Name: Tonscan # Description: Информация о TON адресе # meta developer: @FAmods # meta banner: https://github.com/FajoX1/FAmods/blob/main/assets/banners/tonscan.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 Tonscan(loader.Module): """Информация о TON адресе""" strings = { "name": "Tonscan", "waiting": "🕑 Собираю информацию...", } async def client_ready(self, client, db): self.db = db self._client = client @loader.command() async def tonwallet(self, message): """Информация о TON кошельке""" address = utils.get_args_raw(message) if not address: return await utils.answer(message, f" Должно быть .tonwallet адрес_кошелька") await utils.answer(message, self.strings["waiting"]) async with aiohttp.ClientSession() as session: async with session.get(f"https://tonapi.io/v2/accounts/{address}") as res: response = await res.json() try: response['icon'] ava = f"""Аватарка • """ except: ava = "" try: response['name'] name = f"\nИмя: {response['name']}\n" except: name = "" try: response['error'] if "can't decode address" in response['error']: return await utils.answer(message, f"❌ Это не адрес кошелька!") return await utils.answer(message, f"""❌ Ошибка!\n\n ```json {response['error']} ```""") except: pass scam = "Нет" try: if response['is_scam'] == "True": scam = "Да" except: pass try: contract = f"Контракт: {response['interfaces'][0]}\n" except: contract = "" try: last_activity = f"\nПоследння активность: {datetime.fromtimestamp(response['last_activity'])}" except: last_activity = "" await utils.answer(message, f""" 💎 Ton wallet {name} Адрес: {address} Баланс: {response['balance']} TON Скам: {scam} Статус: {response['status']}{last_activity} {contract} Tonscan • {ava}ИсторияNFTjettonsContract """) @loader.command() async def tonjetton(self, message): """Информация о TON токене""" address = utils.get_args_raw(message) if not address: return await utils.answer(message, f" Должно быть .tonjetton адрес_токена") await utils.answer(message, self.strings["waiting"]) async with aiohttp.ClientSession() as session: async with session.get(f"https://tonapi.io/v2/jettons/{address}") as res: response = await res.json() try: response['error'] return await utils.answer(message, f"""❌ Ошибка!\n\n ```json {response['error']} ```""") except: pass try: response['metadata']['description'] descr = f"\n{response['metadata']['description']}\n" except: descr = "" try: response['metadata']['social'] socials = """Ссылки: """ for s in response['metadata']['social']: socials += s + "\n" socials += "\n" except: socials = "" await utils.answer(message, f""" 💎 Ton jetton Имя: {response['metadata']['name']} Символ: {response['metadata']['symbol']} {descr} Адрес: {address} Общее предложение: {response['total_supply']} TON Количество держателей: {response['holders_count']} {socials}TonscanЛогоИсторияТоп держателейContract """) @loader.command() async def tonnftcol(self, message): """Информация о TON NFT коллекции""" address = utils.get_args_raw(message) if not address: return await utils.answer(message, f" Должно быть .tonnftcol адрес_коллекции") await utils.answer(message, self.strings["waiting"]) async with aiohttp.ClientSession() as session: async with session.get(f"https://tonapi.io/v2/nfts/collections/{address}") as res: response = await res.json() try: response['error'] return await utils.answer(message, f"""❌ Ошибка!\n\n ```json {response['error']} ```""") except: pass try: response['metadata']['description'] descr = f"\n{response['metadata']['description']}\n" except: descr = "" try: response['metadata']['external_link'] external_link = f"\nВнешняя ссылка: {response['metadata']['external_link']}\n" except: external_link = "" try: response['metadata']['social_links'] socials = """Ссылки: """ for s in response['metadata']['social']: socials += s + "\n" socials += "\n" except: socials = "" try: response['metadata']['approved_by'] approved_by = """Одобрено: """ for s in response['metadata']['approved_by']: approved_by += s + "\n" approved_by += "\n" except: approved_by = "" await utils.answer(message, f""" 💎 Ton NFT collection Имя: {response['metadata']['name']} Адрес: {address} {descr} {external_link} {approved_by}{socials}TonscanКоллекцияЛогоБаннер """) @loader.command() async def tonnft(self, message): """Информация о TON NFT""" address = utils.get_args_raw(message) if not address: return await utils.answer(message, f" Должно быть .tonnft адрес_nft") await utils.answer(message, self.strings["waiting"]) async with aiohttp.ClientSession() as session: async with session.get(f"https://tonapi.io/v2/nfts/{address}") as res: response = await res.json() try: response['error'] return await utils.answer(message, f"""❌ Ошибка!\n\n ```json {response['error']} ```""") except: pass try: response['metadata']['description'] descr = f"\n{response['metadata']['description']}\n" except: descr = "" try: response['collection']['name'] coll = f"\nКолекция: {response['collection']['name']}\n" except: coll = "" try: response['metadata']['external_link'] external_link = f"\nВнешняя ссылка: {response['metadata']['external_link']}\n" except: external_link = "" try: response['metadata']['social_links'] socials = """Ссылки: """ for s in response['metadata']['social']: socials += s + "\n" socials += "\n" except: socials = "" try: response['metadata']['approved_by'] approved_by = """Одобрено: """ for s in response['metadata']['approved_by']: approved_by += s + "\n" approved_by += "\n" except: approved_by = "" await utils.answer(message, f""" 💎 Ton NFT {coll} Имя: {response['metadata']['name']} Адрес: {address} {descr} {external_link} {approved_by}{socials}TonscanNFT фото """)