From d394e49fc6bd12dbf7632cd29d36350d5331129a Mon Sep 17 00:00:00 2001 From: Muhammad Awais Machi <130167181+awaiskmalik@users.noreply.github.com> Date: Sat, 30 Dec 2023 14:55:59 +0500 Subject: [PATCH] Add files via upload --- plugins/main-script.js | 54 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 plugins/main-script.js diff --git a/plugins/main-script.js b/plugins/main-script.js new file mode 100644 index 0000000..ff08021 --- /dev/null +++ b/plugins/main-script.js @@ -0,0 +1,54 @@ +import { promises } from 'fs'; +import { join } from 'path'; +import axios from 'axios'; + +let handler = async function (m, { conn, __dirname }) { + const githubRepoURL = 'https://github.com/MalikExperts/MR-MALIK-MD'; + + try { + + const [, username, repoName] = githubRepoURL.match(/github\.com\/([^/]+)\/([^/]+)/); + + const response = await axios.get(`https://api.github.com/repos/${username}/${repoName}`); + + if (response.status === 200) { + const repoData = response.data; + + // Format the repository information with emojis + const formattedInfo = ` +📂 Repository Name: ${repoData.name} +📝 Description: ${repoData.description} +👤 Owner: ${repoData.owner.login} +⭐ Stars: ${repoData.stargazers_count} +🍴 Forks: ${repoData.forks_count} +🌐 URL: ${repoData.html_url} + `.trim(); + + // Send the formatted information as a message + await conn.relayMessage(m.chat, { + requestPaymentMessage: { + currencyCodeIso4217: 'PKR', + amount1000: 69000, + requestFrom: m.sender, + noteMessage: { + extendedTextMessage: { + text: formattedInfo, + contextInfo: { + externalAdReply: { + showAdAttribution: true + }}}}}}, {}) + } else { + // Handle the case where the API request fails + await conn.reply(m.chat, 'Unable to fetch repository information.', m); + } + } catch (error) { + console.error(error); + await conn.reply(m.chat, 'An error occurred while fetching repository information.', m); + } +}; + +handler.help = ['script']; +handler.tags = ['main']; +handler.command = ['sc', 'repo', 'script']; + +export default handler;