2019-07-28 01:52:06 +09:00
|
|
|
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,
|
2020-04-09 00:16:46 +09:00
|
|
|
headers: { Accept: "application/json" },
|
2019-07-28 01:52:06 +09:00
|
|
|
};
|
|
|
|
const response = await fetch(url, options);
|
2020-04-09 00:24:48 +09:00
|
|
|
return say(
|
2019-07-28 01:52:06 +09:00
|
|
|
response.ok
|
|
|
|
? `:nya-n: < ${await response.text()}`
|
|
|
|
: `:nya-n: < がんばったけど ${ip} よくわからんかったにゃん`
|
|
|
|
);
|
2020-04-09 00:16:46 +09:00
|
|
|
},
|
2019-07-28 01:52:06 +09:00
|
|
|
];
|