Skip to content

Commit 737b5bc

Browse files
authored
SILVA MD BOT
1 parent 82515a8 commit 737b5bc

47 files changed

Lines changed: 2017 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

silvaXlab/swsend.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
let handler = async (m, { conn }) => {
2+
// Check if the message is quoting a status broadcast
3+
if (m.quoted?.chat != 'status@broadcast') {
4+
// Do nothing if it's not quoting a status message
5+
return;
6+
}
7+
8+
try {
9+
// Download the content of the quoted status message
10+
let buffer = await m.quoted.download();
11+
12+
// Send the file back to the sender with the quoted message text
13+
await conn.sendFile(m.sender, buffer, '', m.quoted.text || '', null, false, { quoted: m });
14+
} catch (error) {
15+
// Reply with the quoted text in case of error
16+
m.reply(m.quoted.text || '');
17+
}
18+
};
19+
20+
// Help and tag definitions for the handler
21+
handler.help = ['statussave'];
22+
handler.tags = ['tools'];
23+
24+
// Regular expression to match custom prefixes
25+
handler.customPrefix = /send(kro|bro|bhai)|bhejo|Send|send(me|bro|share|nitumie)/i;
26+
27+
// Define the command for the handler (matches all commands)
28+
handler.command = new RegExp;
29+
30+
export default handler;

silvaXlab/test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import fs from 'fs'
2+
import fetch from 'node-fetch'
3+
let handler = async (m, { conn, usedPrefix: _p }) => {
4+
let img = 'https://avatars.githubusercontent.com/u/106463398?v=4'
5+
let info = `*𝐒𝐈𝐋𝐕𝐀 𝐌𝐃 𝐁𝐎𝐓 BOT ACTIVE*`
6+
await conn.reply(m.chat, info, m, {
7+
contextInfo: {
8+
mentionedJid: [m.sender],
9+
forwardingScore: 256,
10+
isForwarded: true,
11+
externalAdReply: {
12+
title: author,
13+
body: botname,
14+
sourceUrl: fgyt,
15+
thumbnail: await conn.getFile(img),
16+
},
17+
},
18+
})
19+
}
20+
handler.customPrefix = /^(tes|tess|test)$/i
21+
handler.command = new RegExp()
22+
23+
export default handler

silvaXlab/textstyle.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import fetch from 'node-fetch';
2+
import { JSDOM } from 'jsdom';
3+
4+
let handler = async (m, { conn, text }) => {
5+
const inputText = text || "SILVA BOT";
6+
console.log('📥 Input text:', inputText);
7+
8+
const styledText = await stylizeText(inputText);
9+
const entries = Object.entries(styledText);
10+
11+
let replyText = entries.map(([name, value]) => {
12+
return `*${name}*\n${value}`;
13+
}).join('\n\n');
14+
15+
console.log('✨ Generated styles:');
16+
console.log(replyText);
17+
18+
await conn.reply(m.chat, replyText, m);
19+
};
20+
21+
handler.help = ['fancy'].map(v => v + ' <text>');
22+
handler.tags = ['tools'];
23+
handler.command = /^(fancy(text)?)$/i;
24+
handler.exp = 0;
25+
26+
export default handler;
27+
28+
async function stylizeText(text) {
29+
const res = await fetch('http://qaz.wtf/u/convert.cgi?text=' + encodeURIComponent(text));
30+
const html = await res.text();
31+
const dom = new JSDOM(html);
32+
const table = dom.window.document.querySelector('table').children[0].children;
33+
const obj = {};
34+
35+
for (let tr of table) {
36+
let name = tr.querySelector('.aname').innerHTML;
37+
let content = tr.children[1].textContent.replace(/^\n/, '').replace(/\n$/, '');
38+
obj[name + (obj[name] ? ' Reversed' : '')] = content;
39+
}
40+
41+
return obj;
42+
}

silvaXlab/tg.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
let handler = async (m, { conn, text, participants, isAdmin, isOwner, groupMetadata }) => {
2+
let users = participants.map(u => u.id).filter(v => v !== conn.user.jid)
3+
m.reply(
4+
`▢ Group : *${groupMetadata.subject}*\n▢ Members : *${participants.length}*${text ? `\n▢ Message : ${text}\n` : ''}\n┌───⊷ *MENTIONS*\n` +
5+
users.map(v => '▢ @' + v.replace(/@.+/, '')).join`\n` +
6+
'\n━━━━━━━━━━𝐒𝐈𝐋𝐕𝐀 𝐌𝐃 𝐁𝐎𝐓━━━━━━━━━━━',
7+
null,
8+
{
9+
mentions: users,
10+
}
11+
)
12+
}
13+
14+
handler.help = ['tagall']
15+
handler.tags = ['group']
16+
handler.command = ['tagall']
17+
handler.admin = true
18+
handler.group = true
19+
20+
export default handler

silvaXlab/tool-dalle.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
import fetch from 'node-fetch';
3+
4+
let handler = async (m, { conn, text, usedPrefix, command }) => {
5+
if (!text) throw `*This command generates images from text prompts*\n\n*𝙴xample usage*\n*◉ ${usedPrefix + command} Beautiful anime girl*\n*◉ ${usedPrefix + command} Elon Musk in pink output*`;
6+
7+
try {
8+
m.reply(imgs);
9+
10+
const endpoint = `https://gurugpt.cyclic.app/dalle?prompt=${encodeURIComponent(text)}`;
11+
const response = await fetch(endpoint);
12+
13+
if (response.ok) {
14+
const imageBuffer = await response.buffer();
15+
await conn.sendFile(m.chat, imageBuffer, 'image.png', null, m);
16+
} else {
17+
throw '*Image generation failed*';
18+
}
19+
} catch {
20+
throw '*Oops! Something went wrong while generating images. Please try again later.*';
21+
}
22+
};
23+
24+
handler.help = ['dalle'];
25+
handler.tags = ['AI'];
26+
handler.command = ['dalle', 'gen', 'gimg', 'openai2'];
27+
export default handler;

silvaXlab/tool-fetch.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
3+
import fetch from 'node-fetch'
4+
import { format } from 'util'
5+
let handler = async (m, { text, conn }) => {
6+
if (!text && !(m.quoted && m.quoted.text)) {
7+
if (!/^https?:\/\//.test(text)) throw `✳️ provide a link...`
8+
}
9+
if (!text && m.quoted && m.quoted.text) {
10+
text = m.quoted.text;
11+
}
12+
let _url = new URL(text)
13+
let url = global.API(_url.origin, _url.pathname, Object.fromEntries(_url.searchParams.entries()), 'APIKEY')
14+
let res = await fetch(url)
15+
if (res.headers.get('content-length') > 100 * 1024 * 1024 * 1024) {
16+
// delete res
17+
throw `Content-Length: ${res.headers.get('content-length')}`
18+
}
19+
if (!/text|json/.test(res.headers.get('content-type'))) return conn.sendFile(m.chat, url, 'file', text, m)
20+
let txt = await res.buffer()
21+
try {
22+
txt = format(JSON.parse(txt + ''))
23+
} catch (e) {
24+
txt = txt + ''
25+
} finally {
26+
m.reply(txt.slice(0, 65536) + '')
27+
}
28+
}
29+
handler.help = ['get']
30+
handler.tags = ['tools']
31+
handler.command = /^(fetch|get)$/i
32+
33+
export default handler

silvaXlab/tool-pdf.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import uploadImage from '../lib/uploadImage.js'
2+
let handler = async (m, { conn, text, usedPrefix, command, isOwner }) => {
3+
let q = m.quoted ? m.quoted : m
4+
let mime = (q.msg || q).mimetype || ''
5+
if (!mime) throw '*Respond / reply to an image*'
6+
let img = await q.download?.()
7+
let url = await uploadImage(img)
8+
let docname = text ? text : m.pushName || 'Gurubot'
9+
conn.sendFile(
10+
m.chat,
11+
`http://api.lolhuman.xyz/api/convert/imgtopdf?apikey=${lolkeysapi}&img=${url}`,
12+
docname + '.pdf',
13+
'',
14+
m,
15+
false,
16+
{ asDocument: true }
17+
)
18+
}
19+
handler.command = /^topdf$/i
20+
export default handler

silvaXlab/tool-shorturl.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import fetch from 'node-fetch'
2+
3+
let handler = async (m, { conn, args, text }) => {
4+
if (!text) throw '*Please provide a URL or link to shorten.*'
5+
6+
let shortUrl1 = await (await fetch(`https://tinyurl.com/api-create.php?url=${args[0]}`)).text()
7+
8+
if (!shortUrl1) throw `*Error: Could not generate a short URL.*`
9+
10+
let done =
11+
`*𝐒𝐈𝐋𝐕𝐀 𝐌𝐃 𝐁𝐎𝐓*\n\n*SHORT URL CREATED!!*\n\n*Original Link:*\n${text}\n*Shortened URL:*\n${shortUrl1}`.trim()
12+
13+
m.reply(done)
14+
}
15+
16+
handler.help = ['tinyurl', 'shorten'].map(v => v + ' <link>')
17+
handler.tags = ['tools']
18+
handler.command = /^(tinyurl|short|acortar|corto)$/i
19+
handler.fail = null
20+
21+
export default handler

silvaXlab/tool-tempmail.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { TempMail } from 'tempmail.lol';
2+
3+
const tempmail = new TempMail();
4+
5+
let handler = async (m, { text, usedPrefix, command }) => {
6+
if (command === 'tempmail') {
7+
try {
8+
const inbox = await tempmail.createInbox();
9+
const emailMessage = `*Temporary Email Address:*\n\n${inbox.address}\n\nA token for checking this inbox will be sent in the next message. Use it with the .checkmail command.`;
10+
await m.reply(emailMessage);
11+
12+
// Send the token as a separate, individual message
13+
await m.reply(inbox.token);
14+
15+
// Send instructions as a third message
16+
await m.reply('Long press and copy the token above to use with the .checkmail command.');
17+
18+
} catch (error) {
19+
console.error('Error:', error);
20+
m.reply('Failed to create a temporary email address.');
21+
}
22+
} else if (command === 'checkmail') {
23+
if (!text) {
24+
m.reply('Please provide the token of the temporary email you want to check.');
25+
return;
26+
}
27+
28+
try {
29+
const emails = await tempmail.checkInbox(text);
30+
if (!emails) {
31+
m.reply(`No messages found or the inbox has expired.`);
32+
return;
33+
}
34+
35+
if (emails.length === 0) {
36+
m.reply(`No messages found in the inbox.`);
37+
return;
38+
}
39+
40+
const messages = emails.map(email => {
41+
return `
42+
*From:* ${email.from}
43+
*Subject:* ${email.subject}
44+
*Date:* ${new Date(email.date).toLocaleString()}
45+
*Body:*
46+
${email.body}
47+
`;
48+
}).join('\n\n---\n\n');
49+
50+
const replyMessage = `*Messages in inbox:*\n\n${messages}`;
51+
m.reply(replyMessage);
52+
} catch (error) {
53+
console.error('Error:', error);
54+
m.reply(`Failed to check messages.`);
55+
}
56+
}
57+
};
58+
59+
handler.help = ['tempmail', 'checkmail <token>'];
60+
handler.tags = ['tools'];
61+
handler.command = ['tempmail', 'checkmail'];
62+
handler.diamond = false;
63+
64+
export default handler;

silvaXlab/tool-whatmusic.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import fs from 'fs'
2+
import acrcloud from 'acrcloud'
3+
let acr = new acrcloud({
4+
host: 'identify-eu-west-1.acrcloud.com',
5+
access_key: 'c33c767d683f78bd17d4bd4991955d81',
6+
access_secret: 'bvgaIAEtADBTbLwiPGYlxupWqkNGIjT7J9Ag2vIu',
7+
})
8+
9+
let handler = async m => {
10+
let q = m.quoted ? m.quoted : m
11+
let mime = (q.msg || q).mimetype || ''
12+
if (/audio|video/.test(mime)) {
13+
let media = await q.download()
14+
let ext = mime.split('/')[1]
15+
fs.writeFileSync(`./tmp/${m.sender}.${ext}`, media)
16+
let res = await acr.identify(fs.readFileSync(`./tmp/${m.sender}.${ext}`))
17+
let { code, msg } = res.status
18+
if (code !== 0) throw msg
19+
let { title, artists, album, genres, release_date } = res.metadata.music[0]
20+
let txt = `
21+
𝚁𝙴𝚂𝚄𝙻𝚃 𝐒𝐈𝐋𝐕𝐀 𝐌𝐃 𝐁𝐎𝐓
22+
• 📌 *TITLE*: ${title}
23+
• 👨‍🎤 𝙰𝚁𝚃𝙸𝚂𝚃: ${artists !== undefined ? artists.map(v => v.name).join(', ') : 'NOT FOUND'}
24+
• 💾 𝙰𝙻𝙱𝚄𝙼: ${album.name || 'NOT FOUND'}
25+
• 🌐 𝙶𝙴𝙽𝙴𝚁: ${genres !== undefined ? genres.map(v => v.name).join(', ') : 'NOT FOUND'}
26+
• 📆 RELEASE DATE: ${release_date || 'NOT FOUND'}
27+
`.trim()
28+
fs.unlinkSync(`./tmp/${m.sender}.${ext}`)
29+
m.reply(txt)
30+
} else throw '*𝚁𝙴𝚂𝙿𝙾𝙽𝙳 𝙰𝚄𝙳𝙸𝙾*'
31+
}
32+
33+
handler.help = ['shazam']
34+
handler.tags = ['tools']
35+
handler.command = /^quemusica|shazam|whatmusic$/i
36+
export default handler

0 commit comments

Comments
 (0)