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/ipinfo.js
2020-04-09 00:24:48 +09:00

19 lines
594 B
JavaScript

const fetch = require("node-fetch");
module.exports = [
/(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])/,
async ({ context, say }) => {
const ip = context.matches[0];
const url = `https://ipinfo.io/${ip}`;
const options = {
timeout: 2000,
headers: { Accept: "application/json" },
};
const response = await fetch(url, options);
return say(
response.ok
? `:nya-n: < ${await response.text()}`
: `:nya-n: < がんばったけど ${ip} よくわからんかったにゃん`
);
},
];