telegramnft.js
cek nft
JSJavaScriptPublicPluginsTanpa lisensiBaileys1 file · 185 baris · 7.1 KBDiperbarui 1 Nov 202617 views
https://codeku.itsuki-nakano.my.id/repo/joootzyh/telegramnft-jscurl -s https://codeku.itsuki-nakano.my.id/raw/joootzyh/telegramnft-jsINFO BOT
- Nama bot
- LulliBot-md
- Prefix perintah
- .telegra
- Versi
- 3.5.0
- Platform
- Baileys
Dependensi
@whiskeysockets/baileys
FILES
telegramnft.js · javascript
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// plugins/tools/telegramnft.js
/*
* Telegram NFT Gift Scraper
* Creator: t.me/FreeScrape
* Type: Plugins ESM
* Modified for Lulli Bot
* Channel: https://whatsapp.com/channel/0029VbCMK1N35fLocOdiz00T
*/
import https from 'node:https';
import * as cheerio from 'cheerio';
class TelegramNFTScraper {
constructor() {
this.userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36';
}
async _fetchHtml(url) {
return new Promise((resolve, reject) => {
const targetUrl = url.startsWith('http') ? url : `https://${url}`;
const req = https.get(targetUrl, {
headers: {
'User-Agent': this.userAgent,
'Accept-Language': 'en-US,en;q=0.9'
}
}, (res) => {
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
return this._fetchHtml(res.headers.location).then(resolve).catch(reject);
}
let data = '';
res.on('data', chunk => data += chunk);
res.on('end', () => resolve(data));
});
req.on('error', reject);
});
}
_getTableValue($, label) {
const row = $('.tgme_gift_table tbody tr').filter((i, el) => {
return $(el).find('th').text().trim() === label;
}).first();
if (row.length === 0) return null;
const tdText = row.find('td').text().trim();
const markText = row.find('mark').text().trim();
return {
value: tdText.replace(markText, '').trim(),
rarity: markText || null
};
}
async scrape(url) {
const html = await this._fetchHtml(url);
const $ = cheerio.load(html);
const title = $('meta[property="og:title"]').attr('content') || $('title').text();
const description = $('meta[property="og:description"]').attr('content') || '';
const imageUrl = $('meta[property="og:image"]').attr('content') || '';
const ownerData = this._getTableValue($, 'Owner');
const modelData = this._getTableValue($, 'Model');
const backdropData = this._getTableValue($, 'Backdrop');
const symbolData = this._getTableValue($, 'Symbol');
const quantityRaw = this._getTableValue($, 'Quantity')?.value || '';
const qtyMatch = quantityRaw.match(/([\d\s]+)\/([\d\s]+)/);
const issued = qtyMatch ? parseInt(qtyMatch[1].replace(/\s/g, '')) : 0;
const total = qtyMatch ? parseInt(qtyMatch[2].replace(/\s/g, '')) : 0;
const deepLink = $('a[href^="tg://nft"]').attr('href') || null;
return {
name: title,
slug: deepLink ? deepLink.split('slug=')[1] : null,
description: description,
image: imageUrl,
attributes: {
model: modelData?.value || null,
modelRarity: modelData?.rarity || null,
backdrop: backdropData?.value || null,
backdropRarity: backdropData?.rarity || null,
symbol: symbolData?.value || null,
symbolRarity: symbolData?.rarity || null
},
supply: {
issued: issued,
total: total,
remaining: total - issued
},
owner: ownerData?.value || null,
deepLink: deepLink
};
}
}
export default {
run: async (a, i, { func, cfg }) => {
const chat = a.chat;
const prefix = a.prefix || '.';
const cmd = (a.cmd || '').toLowerCase().replace(/^[.!?#\/\\]+/, '');
const cmdDisplay = prefix + cmd;
const text = String(a.text || '').trim();
if (!text) {
return i.sendMessage(chat, {
text: `❌ Masukkan link NFT Telegram!\nContoh: *${cmdDisplay} t.me/nft/ViceCream-19430*`
}, { quoted: a });
}
// Validasi URL
const urlMatch = text.match(/(?:https?:\/\/)?t\.me\/nft\/([a-zA-Z0-9_-]+)/i);
if (!urlMatch) {
return i.sendMessage(chat, {
text: `❌ Link tidak valid. Gunakan format seperti *t.me/nft/ViceCream-19430*`
}, { quoted: a });
}
const url = `https://t.me/nft/${urlMatch[1]}`;
await i.sendReact(chat, '⏱️', a.key).catch(() => {});
try {
const scraper = new TelegramNFTScraper();
const data = await scraper.scrape(url);
if (!data.name || data.name.includes('Telegram')) {
throw new Error('Gagal mengambil data. Pastikan link NFT valid dan publik.');
}
// Format Teks
let caption = `🎁 *TELEGRAM NFT GIFT*\n\n`;
caption += `📌 *Name:* ${data.name}\n`;
if (data.description) caption += `📝 *Desc:* ${data.description}\n`;
if (data.slug) caption += `🔗 *Slug:* ${data.slug}\n`;
caption += `\n📦 *Supply:*\n`;
caption += `• Issued: ${data.supply.issued.toLocaleString('id-ID')}\n`;
caption += `• Total: ${data.supply.total.toLocaleString('id-ID')}\n`;
caption += `• Remaining: ${data.supply.remaining.toLocaleString('id-ID')}\n`;
caption += `\n✨ *Attributes:*\n`;
if (data.attributes.model) caption += `• Model: ${data.attributes.model} ${data.attributes.modelRarity ? `(${data.attributes.modelRarity})` : ''}\n`;
if (data.attributes.backdrop) caption += `• Backdrop: ${data.attributes.backdrop} ${data.attributes.backdropRarity ? `(${data.attributes.backdropRarity})` : ''}\n`;
if (data.attributes.symbol) caption += `• Symbol: ${data.attributes.symbol} ${data.attributes.symbolRarity ? `(${data.attributes.symbolRarity})` : ''}\n`;
if (data.owner) caption += `\n👤 *Owner:* ${data.owner}\n`;
// BAGIAN YANG DIUBAH: Mengubah tg:// menjadi https:// agar dibaca sebagai link oleh WhatsApp
if (data.slug) {
const webLink = `https://t.me/nft/${data.slug}`;
caption += `\n📲 *Link:* ${webLink}`;
} else if (data.deepLink) {
caption += `\n📲 *DeepLink:* ${data.deepLink}`;
}
await i.sendReact(chat, '✅', a.key).catch(() => {});
// Kirim Gambar + Caption
if (data.image) {
await i.sendMessage(chat, {
image: { url: data.image },
caption: caption
}, { quoted: a });
} else {
await i.sendMessage(chat, { text: caption }, { quoted: a });
}
} catch (err) {
console.error('[TGNFT] Error:', err.message);
await i.sendReact(chat, '❌', a.key).catch(() => {});
await i.sendMessage(chat, { text: `❌ Gagal mengambil data NFT: ${err.message}` }, { quoted: a });
}
},
cmd: 'telegramnft',
alias: ['tgnft', 'nftgift'],
use: '<link_nft>',
type: 'tools',
location: 'plugins/tools/telegramnft.js'
};PLAYGROUND
Siap
Klik Jalankan untuk melihat output.
Kode berjalan di kotak terisolasi di browser kamu. Tidak punya akses ke cookie, akun, atau server NAKANO CODE, dan tidak bisa membuka koneksi internet. Batas waktu 4 detik. Kode bot yang memanggil library WhatsApp (seperti Baileys) tidak bisa jalan di sini.