Skip to content

Commit

Permalink
SILVA MD BOT
Browse files Browse the repository at this point in the history
  • Loading branch information
SilvaTechB authored Nov 1, 2024
1 parent 82515a8 commit 737b5bc
Show file tree
Hide file tree
Showing 47 changed files with 2,017 additions and 0 deletions.
30 changes: 30 additions & 0 deletions silvaXlab/swsend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
let handler = async (m, { conn }) => {
// Check if the message is quoting a status broadcast
if (m.quoted?.chat != 'status@broadcast') {
// Do nothing if it's not quoting a status message
return;
}

try {
// Download the content of the quoted status message
let buffer = await m.quoted.download();

// Send the file back to the sender with the quoted message text
await conn.sendFile(m.sender, buffer, '', m.quoted.text || '', null, false, { quoted: m });
} catch (error) {
// Reply with the quoted text in case of error
m.reply(m.quoted.text || '');
}
};

// Help and tag definitions for the handler
handler.help = ['statussave'];
handler.tags = ['tools'];

// Regular expression to match custom prefixes
handler.customPrefix = /send(kro|bro|bhai)|bhejo|Send|send(me|bro|share|nitumie)/i;

// Define the command for the handler (matches all commands)
handler.command = new RegExp;

export default handler;
23 changes: 23 additions & 0 deletions silvaXlab/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import fs from 'fs'
import fetch from 'node-fetch'
let handler = async (m, { conn, usedPrefix: _p }) => {
let img = 'https://avatars.githubusercontent.com/u/106463398?v=4'
let info = `*𝐒𝐈𝐋𝐕𝐀 𝐌𝐃 𝐁𝐎𝐓 BOT ACTIVE*`
await conn.reply(m.chat, info, m, {
contextInfo: {
mentionedJid: [m.sender],
forwardingScore: 256,
isForwarded: true,
externalAdReply: {
title: author,
body: botname,
sourceUrl: fgyt,
thumbnail: await conn.getFile(img),
},
},
})
}
handler.customPrefix = /^(tes|tess|test)$/i
handler.command = new RegExp()

export default handler
42 changes: 42 additions & 0 deletions silvaXlab/textstyle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import fetch from 'node-fetch';
import { JSDOM } from 'jsdom';

let handler = async (m, { conn, text }) => {
const inputText = text || "SILVA BOT";
console.log('📥 Input text:', inputText);

const styledText = await stylizeText(inputText);
const entries = Object.entries(styledText);

let replyText = entries.map(([name, value]) => {
return `*${name}*\n${value}`;
}).join('\n\n');

console.log('✨ Generated styles:');
console.log(replyText);

await conn.reply(m.chat, replyText, m);
};

handler.help = ['fancy'].map(v => v + ' <text>');
handler.tags = ['tools'];
handler.command = /^(fancy(text)?)$/i;
handler.exp = 0;

export default handler;

async function stylizeText(text) {
const res = await fetch('http://qaz.wtf/u/convert.cgi?text=' + encodeURIComponent(text));
const html = await res.text();
const dom = new JSDOM(html);
const table = dom.window.document.querySelector('table').children[0].children;
const obj = {};

for (let tr of table) {
let name = tr.querySelector('.aname').innerHTML;
let content = tr.children[1].textContent.replace(/^\n/, '').replace(/\n$/, '');
obj[name + (obj[name] ? ' Reversed' : '')] = content;
}

return obj;
}
20 changes: 20 additions & 0 deletions silvaXlab/tg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
let handler = async (m, { conn, text, participants, isAdmin, isOwner, groupMetadata }) => {
let users = participants.map(u => u.id).filter(v => v !== conn.user.jid)
m.reply(
`▢ Group : *${groupMetadata.subject}*\n▢ Members : *${participants.length}*${text ? `\n▢ Message : ${text}\n` : ''}\n┌───⊷ *MENTIONS*\n` +
users.map(v => '▢ @' + v.replace(/@.+/, '')).join`\n` +
'\n━━━━━━━━━━𝐒𝐈𝐋𝐕𝐀 𝐌𝐃 𝐁𝐎𝐓━━━━━━━━━━━',
null,
{
mentions: users,
}
)
}

handler.help = ['tagall']
handler.tags = ['group']
handler.command = ['tagall']
handler.admin = true
handler.group = true

export default handler
27 changes: 27 additions & 0 deletions silvaXlab/tool-dalle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

import fetch from 'node-fetch';

let handler = async (m, { conn, text, usedPrefix, command }) => {
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*`;

try {
m.reply(imgs);

const endpoint = `https://gurugpt.cyclic.app/dalle?prompt=${encodeURIComponent(text)}`;
const response = await fetch(endpoint);

if (response.ok) {
const imageBuffer = await response.buffer();
await conn.sendFile(m.chat, imageBuffer, 'image.png', null, m);
} else {
throw '*Image generation failed*';
}
} catch {
throw '*Oops! Something went wrong while generating images. Please try again later.*';
}
};

handler.help = ['dalle'];
handler.tags = ['AI'];
handler.command = ['dalle', 'gen', 'gimg', 'openai2'];
export default handler;
33 changes: 33 additions & 0 deletions silvaXlab/tool-fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@


import fetch from 'node-fetch'
import { format } from 'util'
let handler = async (m, { text, conn }) => {
if (!text && !(m.quoted && m.quoted.text)) {
if (!/^https?:\/\//.test(text)) throw `✳️ provide a link...`
}
if (!text && m.quoted && m.quoted.text) {
text = m.quoted.text;
}
let _url = new URL(text)
let url = global.API(_url.origin, _url.pathname, Object.fromEntries(_url.searchParams.entries()), 'APIKEY')
let res = await fetch(url)
if (res.headers.get('content-length') > 100 * 1024 * 1024 * 1024) {
// delete res
throw `Content-Length: ${res.headers.get('content-length')}`
}
if (!/text|json/.test(res.headers.get('content-type'))) return conn.sendFile(m.chat, url, 'file', text, m)
let txt = await res.buffer()
try {
txt = format(JSON.parse(txt + ''))
} catch (e) {
txt = txt + ''
} finally {
m.reply(txt.slice(0, 65536) + '')
}
}
handler.help = ['get']
handler.tags = ['tools']
handler.command = /^(fetch|get)$/i

export default handler
20 changes: 20 additions & 0 deletions silvaXlab/tool-pdf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import uploadImage from '../lib/uploadImage.js'
let handler = async (m, { conn, text, usedPrefix, command, isOwner }) => {
let q = m.quoted ? m.quoted : m
let mime = (q.msg || q).mimetype || ''
if (!mime) throw '*Respond / reply to an image*'
let img = await q.download?.()
let url = await uploadImage(img)
let docname = text ? text : m.pushName || 'Gurubot'
conn.sendFile(
m.chat,
`http://api.lolhuman.xyz/api/convert/imgtopdf?apikey=${lolkeysapi}&img=${url}`,
docname + '.pdf',
'',
m,
false,
{ asDocument: true }
)
}
handler.command = /^topdf$/i
export default handler
21 changes: 21 additions & 0 deletions silvaXlab/tool-shorturl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import fetch from 'node-fetch'

let handler = async (m, { conn, args, text }) => {
if (!text) throw '*Please provide a URL or link to shorten.*'

let shortUrl1 = await (await fetch(`https://tinyurl.com/api-create.php?url=${args[0]}`)).text()

if (!shortUrl1) throw `*Error: Could not generate a short URL.*`

let done =
`*𝐒𝐈𝐋𝐕𝐀 𝐌𝐃 𝐁𝐎𝐓*\n\n*SHORT URL CREATED!!*\n\n*Original Link:*\n${text}\n*Shortened URL:*\n${shortUrl1}`.trim()

m.reply(done)
}

handler.help = ['tinyurl', 'shorten'].map(v => v + ' <link>')
handler.tags = ['tools']
handler.command = /^(tinyurl|short|acortar|corto)$/i
handler.fail = null

export default handler
64 changes: 64 additions & 0 deletions silvaXlab/tool-tempmail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { TempMail } from 'tempmail.lol';

const tempmail = new TempMail();

let handler = async (m, { text, usedPrefix, command }) => {
if (command === 'tempmail') {
try {
const inbox = await tempmail.createInbox();
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.`;
await m.reply(emailMessage);

// Send the token as a separate, individual message
await m.reply(inbox.token);

// Send instructions as a third message
await m.reply('Long press and copy the token above to use with the .checkmail command.');

} catch (error) {
console.error('Error:', error);
m.reply('Failed to create a temporary email address.');
}
} else if (command === 'checkmail') {
if (!text) {
m.reply('Please provide the token of the temporary email you want to check.');
return;
}

try {
const emails = await tempmail.checkInbox(text);
if (!emails) {
m.reply(`No messages found or the inbox has expired.`);
return;
}

if (emails.length === 0) {
m.reply(`No messages found in the inbox.`);
return;
}

const messages = emails.map(email => {
return `
*From:* ${email.from}
*Subject:* ${email.subject}
*Date:* ${new Date(email.date).toLocaleString()}
*Body:*
${email.body}
`;
}).join('\n\n---\n\n');

const replyMessage = `*Messages in inbox:*\n\n${messages}`;
m.reply(replyMessage);
} catch (error) {
console.error('Error:', error);
m.reply(`Failed to check messages.`);
}
}
};

handler.help = ['tempmail', 'checkmail <token>'];
handler.tags = ['tools'];
handler.command = ['tempmail', 'checkmail'];
handler.diamond = false;

export default handler;
36 changes: 36 additions & 0 deletions silvaXlab/tool-whatmusic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import fs from 'fs'
import acrcloud from 'acrcloud'
let acr = new acrcloud({
host: 'identify-eu-west-1.acrcloud.com',
access_key: 'c33c767d683f78bd17d4bd4991955d81',
access_secret: 'bvgaIAEtADBTbLwiPGYlxupWqkNGIjT7J9Ag2vIu',
})

let handler = async m => {
let q = m.quoted ? m.quoted : m
let mime = (q.msg || q).mimetype || ''
if (/audio|video/.test(mime)) {
let media = await q.download()
let ext = mime.split('/')[1]
fs.writeFileSync(`./tmp/${m.sender}.${ext}`, media)
let res = await acr.identify(fs.readFileSync(`./tmp/${m.sender}.${ext}`))
let { code, msg } = res.status
if (code !== 0) throw msg
let { title, artists, album, genres, release_date } = res.metadata.music[0]
let txt = `
𝚁𝙴𝚂𝚄𝙻𝚃 𝐒𝐈𝐋𝐕𝐀 𝐌𝐃 𝐁𝐎𝐓
• 📌 *TITLE*: ${title}
• 👨‍🎤 𝙰𝚁𝚃𝙸𝚂𝚃: ${artists !== undefined ? artists.map(v => v.name).join(', ') : 'NOT FOUND'}
• 💾 𝙰𝙻𝙱𝚄𝙼: ${album.name || 'NOT FOUND'}
• 🌐 𝙶𝙴𝙽𝙴𝚁: ${genres !== undefined ? genres.map(v => v.name).join(', ') : 'NOT FOUND'}
• 📆 RELEASE DATE: ${release_date || 'NOT FOUND'}
`.trim()
fs.unlinkSync(`./tmp/${m.sender}.${ext}`)
m.reply(txt)
} else throw '*𝚁𝙴𝚂𝙿𝙾𝙽𝙳 𝙰𝚄𝙳𝙸𝙾*'
}

handler.help = ['shazam']
handler.tags = ['tools']
handler.command = /^quemusica|shazam|whatmusic$/i
export default handler
20 changes: 20 additions & 0 deletions silvaXlab/tool-ytcomment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
let handler = async (m, { conn, text }) => {
if (!text) throw 'No Text'
conn.sendFile(
m.chat,
global.API('https://some-random-api.com', '/canvas/misc/youtube-comment', {
avatar: await conn
.profilePictureUrl(m.sender, 'image')
.catch(_ => 'https://telegra.ph/file/24fa902ead26340f3df2c.png'),
comment: text,
username: conn.getName(m.sender),
}),
'error.png',
'*THANKS FOR COMMENT*',
m
)
}
handler.help = ['ytcomment <comment>']
handler.tags = ['maker']
handler.command = /^(ytcomment)$/i
export default handler
40 changes: 40 additions & 0 deletions silvaXlab/tools-animeinfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { translate } from '@vitalets/google-translate-api'
import { Anime } from '@shineiichijo/marika'

const client = new Anime()

let handler = async (m, { conn, text, usedPrefix }) => {
if (!text) return m.reply(`*[❗] Please enter the name of an anime to search for.*`)
try {
let anime = await client.searchAnime(text)
let result = anime.data[0]
let resultes = await translate(`${result.background}`, { to: 'en', autoCorrect: true })
let resultes2 = await translate(`${result.synopsis}`, { to: 'hi', autoCorrect: true })
let AnimeInfo = ` 𝐒𝐈𝐋𝐕𝐀 𝐌𝐃 𝐁𝐎𝐓
🎀 • *Title:* ${result.title}
🎋 • *Format:* ${result.type}
📈 • *Status:* ${result.status.toUpperCase().replace(/\_/g, ' ')}
🍥 • *Total Episodes:* ${result.episodes}
🎈 • *Duration: ${result.duration}*
✨ • *Based on:* ${result.source.toUpperCase()}
💫 • *Released:* ${result.aired.from}
🎗 • *Finished:* ${result.aired.to}
🎐 • *Popularity:* ${result.popularity}
🎏 • *Favorites:* ${result.favorites}
🎇 • *Rating:* ${result.rating}
🏅 • *Rank:* ${result.rank}
♦ • *Trailer:* ${result.trailer.url}
🌐 • *URL:* ${result.url}
🎆 • *Background:* ${resultes.text}
❄ • *Synopsis:* ${resultes2.text}`

conn.sendFile(m.chat, result.images.jpg.image_url, 'error.jpg', AnimeInfo, m)
} catch {
throw `*[❗] ERROR, please try again.*`
}
}

handler.help = ['anime']
handler.tags = ['anime']
handler.command = /^(anime|animeinfo)$/i
export default handler
Loading

0 comments on commit 737b5bc

Please sign in to comment.