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