Spaces:
Paused
Paused
Download commands/Menu.js from Mega-Evolutions/empty: direct link, hf CLI and curl.
- Browser
- Download file 16 kB
-
https://huggingface.co/spaces/Mega-Evolutions/empty/resolve/main/commands/Menu.js
- Command line
-
hf download hf://spaces/Mega-Evolutions/empty/commands/Menu.js
-
curl -L -o Menu.js https://huggingface.co/spaces/Mega-Evolutions/empty/resolve/main/commands/Menu.js
16 kB
| import os from 'os'; | |
| import moment from 'moment-timezone'; | |
| import axios from 'axios'; | |
| import CONFIG from '../config.js'; | |
| import { t, translate, translateAIResponse, getUserLang } from '../france/translator.js'; | |
| const startTime = Date.now(); | |
| const styles = { | |
| 10: { | |
| "0": "0", "1": "1", "2": "2", "3": "3", "4": "4", "5": "5", "6": "6", "7": "7", "8": "8", "9": "9", | |
| "a": "แด", "b": "ส", "c": "แด", "d": "แด ", "e": "แด", "f": "า", "g": "ษข", "h": "ส", "i": "ษช", "j": "แด", | |
| "k": "แด", "l": "ส", "m": "แด", "n": "ษด", "o": "แด", "p": "แด", "q": "ฯ", "r": "ส", "s": "s", "t": "แด", | |
| "u": "แด", "v": "v", "w": "แดก", "x": "x", "y": "ส", "z": "แดข", "A": "แด", "B": "ส", "C": "แด", "D": "แด ", | |
| "E": "แด", "F": "า", "G": "ษข", "H": "ส", "I": "ษช", "J": "แด", "K": "แด", "L": "ส", "M": "แด", "N": "ษด", | |
| "O": "แด", "P": "แด", "Q": "ฯ", "R": "ส", "S": "s", "T": "แด", "U": "แด", "V": "v", "W": "แดก", "X": "x", | |
| "Y": "ส", "Z": "แดข" | |
| } | |
| }; | |
| const applyStyle = (text, styleNum) => { | |
| const map = styles[styleNum]; | |
| return text.split('').map(c => map[c] || c).join(''); | |
| }; | |
| const formatUptime = ms => { | |
| const sec = Math.floor(ms / 1000) % 60; | |
| const min = Math.floor(ms / (1000 * 60)) % 60; | |
| const hr = Math.floor(ms / (1000 * 60 * 60)) % 24; | |
| const day = Math.floor(ms / (1000 * 60 * 60 * 24)); | |
| const parts = []; | |
| if (day === 1) parts.push(`1 day`); | |
| else if (day > 1) parts.push(`${day} days`); | |
| if (hr === 1) parts.push(`1 hour`); | |
| else if (hr > 1) parts.push(`${hr} h`); | |
| if (min === 1) parts.push(`1 minute`); | |
| else if (min > 1) parts.push(`${min} m`); | |
| if (sec === 1) parts.push(`1 second`); | |
| else if (sec > 1 || parts.length === 0) parts.push(`${sec} s`); | |
| return parts.join(', '); | |
| }; | |
| const detectPlatform = () => { | |
| const hostEnv = process.env.HOST_PROVIDER?.toLowerCase(); | |
| const providers = { | |
| 'optiklink': 'Optiklink.com', | |
| 'bot-hosting': 'Bot-Hosting.net', | |
| 'heroku': 'Heroku', | |
| 'railway': 'Railway', | |
| 'koyeb': 'Koyeb', | |
| 'render': 'Render', | |
| 'github': 'GitHub Actions', | |
| 'katabump': 'Katabump.com' | |
| }; | |
| if (hostEnv && providers[hostEnv]) return providers[hostEnv]; | |
| if (process.env.RAILWAY_STATIC_URL || process.env.RAILWAY_ENVIRONMENT) return 'Railway'; | |
| if (process.env.KOYEB_ENV) return 'Koyeb'; | |
| if (process.env.RENDER) return 'Render'; | |
| if (process.env.GITHUB_WORKFLOW || process.env.GITHUB_ACTIONS) return 'GitHub Actions'; | |
| if (process.env.DYNO) return 'Heroku'; | |
| return 'PANEL'; | |
| }; | |
| const fetchRepoStats = async () => { | |
| try { | |
| const response = await axios.get('https://api.github.com/repos/franceking1/Flash-Md-V3'); | |
| const { forks_count, stargazers_count } = response.data; | |
| return { | |
| forks: forks_count || 0, | |
| stars: stargazers_count || 0 | |
| }; | |
| } catch { | |
| return { | |
| forks: 0, | |
| stars: 0 | |
| }; | |
| } | |
| }; | |
| const more = String.fromCharCode(8206); | |
| const readmore = more.repeat(4001); | |
| export const commands = [ | |
| { | |
| name: 'menu', | |
| aliases: ['list'], | |
| description: 'Show all available bot commands.', | |
| category: 'General', | |
| execute: async ({ sock, from, msg, commands, auteurMessage, nomAuteurMessage }) => { | |
| try { | |
| const botName = 'FLASH-MD-V3'; | |
| const botVersion = CONFIG.BOT_VERSION || '3.0.0'; | |
| const ownerName = CONFIG.OWNER_NAME || 'FRANCE KING'; | |
| const tz = CONFIG.TZ || 'Africa/Nairobi'; | |
| const prefix = CONFIG.PREFIXES?.[0] || ' '; | |
| const mode = CONFIG.MODE === 'public' ? 'Public' : 'Private'; | |
| const menuImages = CONFIG.MENU_IMAGES || []; | |
| const list = Array.from(commands.values()); | |
| if (!list.length) { | |
| return sock.sendMessage(from, { | |
| text: 'โ Command list not available.' | |
| }, { quoted: msg }); | |
| } | |
| const time = moment().tz(tz); | |
| const hour = time.hour(); | |
| let greeting = "Good Night"; | |
| if (hour >= 0 && hour <= 11) { | |
| greeting = "Good Morning"; | |
| } else if (hour >= 12 && hour <= 16) { | |
| greeting = "Good Afternoon"; | |
| } else if (hour >= 16 && hour <= 21) { | |
| greeting = "Good Evening"; | |
| } | |
| const userName = nomAuteurMessage || auteurMessage || ownerName; | |
| const uptime = formatUptime(Date.now() - startTime); | |
| const platform = detectPlatform(); | |
| const usedMem = ( | |
| (os.totalmem() - os.freemem()) / | |
| 1024 / | |
| 1024 / | |
| 1024 | |
| ).toFixed(2); | |
| const totalMem = ( | |
| os.totalmem() / | |
| 1024 / | |
| 1024 / | |
| 1024 | |
| ).toFixed(2); | |
| const { forks, stars } = await fetchRepoStats(); | |
| const users = (stars * 3) + (forks * 2); | |
| const usersFormatted = users.toLocaleString(); | |
| const grouped = {}; | |
| for (const cmd of list) { | |
| const category = cmd.category || 'General'; | |
| if (!grouped[category]) { | |
| grouped[category] = []; | |
| } | |
| grouped[category].push(cmd); | |
| } | |
| let menuText = `*${greeting} ${userName}*\n\n`; | |
| menuText += `โญโโโโ ${applyStyle(`${botName} ${botVersion}`, 10)} โโโโโฎ\n`; | |
| menuText += `โโโญโโโโโโโโโโโโโโโโ\n`; | |
| menuText += `โโโ *Owner:* ${ownerName}\n`; | |
| menuText += `โโโ *Prefix:* ${prefix}\n`; | |
| menuText += `โโโ *Commands:* ${list.length}\n`; | |
| menuText += `โโโ *Time:* ${time.format('HH:mm:ss')}\n`; | |
| menuText += `โโโ *Date:* ${time.format('DD/MM/YYYY')}\n`; | |
| menuText += `โโโ *Mode:* ${mode}\n`; | |
| menuText += `โโโ *Timezone:* ${tz}\n`; | |
| menuText += `โโโ *Total Users:* ${usersFormatted}\n`; | |
| menuText += `โโโ *RAM:* ${usedMem}/${totalMem} GB\n`; | |
| menuText += `โโโ *Uptime:* ${uptime}\n`; | |
| menuText += `โโโ *Platform:* ${platform}\n`; | |
| menuText += `โโโฐโโโโโโโโโโโโโโโโ\n`; | |
| menuText += `โฐโโโโโโ ${applyStyle(`VERSION ${botVersion}`, 10)} โโโโโโฏ\n\n`; | |
| menuText += `*โ ${botName} COMMANDS โ*\n\n`; | |
| let counter = 1; | |
| const sortedCategories = Object.keys(grouped).sort(); | |
| for (const category of sortedCategories) { | |
| const commandsInCategory = grouped[category] | |
| .filter(c => c.name) | |
| .sort((a, b) => a.name.localeCompare(b.name)); | |
| if (commandsInCategory.length === 0) continue; | |
| menuText += `*โญโโโ ${applyStyle(category.toUpperCase(), 10)} โโโโโท*\n`; | |
| menuText += `โโญโโโโโโโโโโโโ\n`; | |
| for (const cmd of commandsInCategory) { | |
| menuText += `โโ ${counter++}. ${applyStyle(cmd.name, 10)}\n`; | |
| } | |
| menuText += `โโฐโโโโโโโโโโโโ\n`; | |
| menuText += `โฐโโโโโโโโโโโโโโโท\n\n`; | |
| } | |
| menuText += `${readmore}\n`; | |
| menuText += `โ *THE FLASH MULTI DEVICE* โ\n\n`; | |
| menuText += ` *Released: 22.2.2024*\n\n`; | |
| menuText += ` _Thanks For choosing ${botName}_\n\n`; | |
| menuText += ` Created by *${ownerName} ยฉ2024*\n\n`; | |
| menuText += ` *KEEP USING ${botName}*\n`; | |
| const defaultMedia = [ | |
| 'https://picsum.photos/700/900', | |
| 'https://h.uguu.se/qhKuTfqE.mp4' | |
| ]; | |
| const allMedia = [...defaultMedia, ...menuImages]; | |
| const randomImage = allMedia[ | |
| Math.floor(Math.random() * allMedia.length) | |
| ]; | |
| const isVideo = randomImage.endsWith('.mp4'); | |
| try { | |
| await sock.sendMessage(from, { | |
| ...(isVideo | |
| ? { video: { url: randomImage } } | |
| : { image: { url: randomImage } }), | |
| caption: menuText, | |
| contextInfo: { | |
| mentionedJid: [userName], | |
| forwardingScore: 1, | |
| isForwarded: true, | |
| forwardedNewsletterMessageInfo: { | |
| newsletterJid: '120363238139244263@newsletter', | |
| newsletterName: botName, | |
| serverMessageId: -1 | |
| } | |
| } | |
| }, { quoted: msg }); | |
| } catch { | |
| await sock.sendMessage(from, { | |
| text: menuText, | |
| contextInfo: { | |
| mentionedJid: [userName], | |
| forwardingScore: 1, | |
| isForwarded: true, | |
| forwardedNewsletterMessageInfo: { | |
| newsletterJid: '120363238139244263@newsletter', | |
| newsletterName: botName, | |
| serverMessageId: -1 | |
| } | |
| } | |
| }, { quoted: msg }); | |
| } | |
| } catch (error) { | |
| console.error('Menu error:', error); | |
| await sock.sendMessage(from, { | |
| text: 'โ Error loading menu.' | |
| }, { quoted: msg }); | |
| } | |
| } | |
| }, | |
| { | |
| name: 'help', | |
| aliases: ['guide'], | |
| description: 'Show command details with descriptions and aliases.', | |
| category: 'General', | |
| execute: async ({ sock, from, text, msg, commands, auteurMessage, nomAuteurMessage }) => { | |
| try { | |
| const botName = 'FLASH-MD-V3'; | |
| const botVersion = CONFIG.BOT_VERSION || '3.0.0'; | |
| const ownerName = CONFIG.OWNER_NAME || 'FRANCE KING'; | |
| const tz = CONFIG.TZ || 'Africa/Nairobi'; | |
| const prefix = CONFIG.PREFIXES?.[0] || ' '; | |
| const list = Array.from(commands.values()); | |
| if (!list.length) { | |
| const noCommandsMsg = await t(from, 'help', 'noCommands'); | |
| return sock.sendMessage(from, { | |
| text: noCommandsMsg | |
| }, { quoted: msg }); | |
| } | |
| const time = moment().tz(tz); | |
| const hour = time.hour(); | |
| let greeting = "Good Night"; | |
| if (hour >= 0 && hour <= 11) { | |
| greeting = "Good Morning"; | |
| } else if (hour >= 12 && hour <= 16) { | |
| greeting = "Good Afternoon"; | |
| } else if (hour >= 16 && hour <= 21) { | |
| greeting = "Good Evening"; | |
| } | |
| const userName = nomAuteurMessage || auteurMessage || ownerName; | |
| const greetingMsg = await t(from, 'help', 'greeting'); | |
| const ownerLabel = await t(from, 'help', 'owner'); | |
| const prefixLabel = await t(from, 'help', 'prefix'); | |
| const timeLabel = await t(from, 'help', 'time'); | |
| const dateLabel = await t(from, 'help', 'date'); | |
| const tzLabel = await t(from, 'help', 'timezone'); | |
| const noDescMsg = await t(from, 'help', 'noDescription'); | |
| const aliasesLabel = await t(from, 'help', 'aliases'); | |
| const usageMsg = await t(from, 'help', 'usage'); | |
| const poweredMsg = await t(from, 'help', 'powered'); | |
| let helpText = `${greetingMsg} ${userName}\n\n`; | |
| helpText += `โญโโโโ ${applyStyle(`${botName}`, 10)} โโโโโฎ\n`; | |
| helpText += `โโโญโโโโโโโโโโโโโโโโ\n`; | |
| helpText += `โโโ *${ownerLabel}:* ${ownerName}\n`; | |
| helpText += `โโโ *${prefixLabel}:* ${prefix}\n`; | |
| helpText += `โโโ *${timeLabel}:* ${time.format('HH:mm:ss')}\n`; | |
| helpText += `โโโ *${dateLabel}:* ${time.format('DD/MM/YYYY')}\n`; | |
| helpText += `โโโ *${tzLabel}:* ${tz}\n`; | |
| helpText += `โโโฐโโโโโโโโโโโโโโโโ\n`; | |
| helpText += `โฐโโโโโโโโโโโโโโโโโโโโโโโโฏ\n\n`; | |
| helpText += `*FLASH-MD V3 COMMANDS*\n\n`; | |
| const grouped = {}; | |
| for (const cmd of list) { | |
| const category = cmd.category || 'General'; | |
| if (!grouped[category]) { | |
| grouped[category] = []; | |
| } | |
| grouped[category].push(cmd); | |
| } | |
| const sortedCategories = Object.keys(grouped).sort(); | |
| for (const category of sortedCategories) { | |
| const commandsInCategory = grouped[category] | |
| .filter(c => c.name) | |
| .sort((a, b) => a.name.localeCompare(b.name)); | |
| if (commandsInCategory.length === 0) continue; | |
| helpText += `โญโโโ ${applyStyle(category.toUpperCase(), 10)} โโโโโท\n`; | |
| helpText += `โ\n`; | |
| for (const cmd of commandsInCategory) { | |
| helpText += `โ โข *${applyStyle(cmd.name, 10)}*\n`; | |
| helpText += `โ โณ ${cmd.description || noDescMsg}\n`; | |
| if (cmd.aliases && cmd.aliases.length > 0) { | |
| helpText += `โ โณ ${aliasesLabel}: ${cmd.aliases.map(a => applyStyle(a, 10)).join(', ')}\n`; | |
| } | |
| helpText += `โ\n`; | |
| } | |
| helpText += `โฐโโโโโโโโโโโโโโโท\n\n`; | |
| } | |
| helpText += `${usageMsg} ${prefix}<command>\n`; | |
| helpText += `${poweredMsg} ${botName} ${botVersion}`; | |
| await sock.sendMessage(from, { | |
| text: helpText, | |
| contextInfo: { | |
| mentionedJid: [userName], | |
| forwardingScore: 1, | |
| isForwarded: true, | |
| forwardedNewsletterMessageInfo: { | |
| newsletterJid: '120363238139244263@newsletter', | |
| newsletterName: botName, | |
| serverMessageId: -1 | |
| } | |
| } | |
| }, { quoted: msg }); | |
| } catch (error) { | |
| console.error('Help error:', error); | |
| const errorMsg = await t(from, 'help', 'error'); | |
| await sock.sendMessage(from, { | |
| text: errorMsg | |
| }, { quoted: msg }); | |
| } | |
| } | |
| } | |
| ]; | |