1
0
Fork 0
mirror of https://github.com/kou029w/daraz-san.git synced 2025-01-18 16:08:06 +00:00
daraz-san/scripts/dns.js

25 lines
729 B
JavaScript
Raw Normal View History

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)
)
);
2020-04-09 00:24:48 +09:00
return say(
`:nya-n: < ${domain}${records.join(" *,* ")} ですにゃん`
);
} catch {
2020-04-09 00:24:48 +09:00
return say(`:nya-n: < ${domain} はわかんなかったにゃん`);
}
2020-04-09 00:16:46 +09:00
},
];