forked from AyGemuy/Taylor-V2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch-github2.js
More file actions
52 lines (50 loc) · 1.81 KB
/
Copy pathsearch-github2.js
File metadata and controls
52 lines (50 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import fetch from "node-fetch";
const formatDate = (n, locale = "id") => new Date(n).toLocaleDateString(locale, {
weekday: "long",
day: "numeric",
month: "long",
year: "numeric",
hour: "numeric",
minute: "numeric",
second: "numeric"
});
const searchGit = async text => {
try {
const res = await fetch(`https://api.github.com/search/repositories?q=${encodeURIComponent(text)}`);
if (!res.ok) throw new Error(`Failed to fetch data from GitHub: ${res.statusText}`);
return await res.json();
} catch (error) {
throw new Error(`Error fetching data: ${error.message}`);
}
};
const handler = async (m, {
text,
command,
usedPrefix
}) => {
if (!text) return m.reply(`Contoh:\n${usedPrefix + command} Taylor-V2`);
m.react(wait);
try {
const json = await searchGit(text);
const str = json.items.map((repo, index) => `
> 「 ${index + 1} 」 <
ɴᴀᴍᴇ ʀᴇᴘᴏ : ${repo.name}
ʙʏ : ${repo.owner.login}
ғᴏʀᴋᴇᴅ : ${repo.fork ? "True" : "False"}
ᴘʀɪᴠᴀᴛᴇ : ${repo.private ? "True" : "False"}
➔ ᴄʀᴇᴀᴛᴇᴅ ᴏɴ : ${formatDate(repo.created_at)}
➔ ʟᴀsᴛ ᴜᴘᴅᴀᴛᴇᴅ ᴏɴ : ${formatDate(repo.updated_at)}
👁 ${repo.watchers} 🍴 ${repo.forks} ⭐ ${repo.stargazers_count}
❗ ɪssᴜᴇ : ${repo.open_issues} ${repo.description ? `\n📚 ᴅᴇsᴄʀɪᴘᴛɪᴏɴ:\n${repo.description}` : ""}
⑂ ᴄʟᴏɴᴇ :
$ git clone ${repo.clone_url}
`.trim()).join("\n— — — — — — — — — — — — — —\n");
await conn.reply(m.chat, `*${htki} ɢɪᴛʜᴜʙ sᴇᴀʀᴄʜ ${htka}*\n${str}`, m);
} catch (error) {
m.react(eror);
}
};
handler.help = ["githubsearch"].map(v => v + " <pencarian>");
handler.tags = ["internet", "downloader"];
handler.command = /^g(ithub|h)s(earch)$/i;
export default handler;