mirror of
https://github.com/kou029w/daraz-san.git
synced 2025-01-18 16:08:06 +00:00
24 lines
729 B
JavaScript
24 lines
729 B
JavaScript
const dns = require("dns");
|
|
const { tldExists } = require("tldjs");
|
|
|
|
module.exports = [
|
|
/(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)+([a-z]+)/,
|
|
async ({ context, say }) => {
|
|
const domain = context.matches[0];
|
|
const ignores = ["daraz-tek.slack.com"];
|
|
if (ignores.includes(domain)) return;
|
|
if (!tldExists(domain)) return;
|
|
try {
|
|
const records = await new Promise((resolve, reject) =>
|
|
dns.resolve(domain, (err, records) =>
|
|
err ? reject(err) : resolve(records)
|
|
)
|
|
);
|
|
return say(
|
|
`:nya-n: < ${domain} は ${records.join(" *,* ")} ですにゃん`
|
|
);
|
|
} catch {
|
|
return say(`:nya-n: < ${domain} はわかんなかったにゃん`);
|
|
}
|
|
},
|
|
];
|