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

20 lines
594 B
JavaScript
Raw Normal View History

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