Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
awaiskmalik authored Dec 30, 2023
1 parent 9b1b92f commit d394e49
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions plugins/main-script.js
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit d394e49

Please sign in to comment.