-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b1b92f
commit d394e49
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |