mirror of
https://github.com/kou029w/daraz-san.git
synced 2025-01-19 00:18:01 +00:00
20 lines
585 B
JavaScript
20 lines
585 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);
|
||
|
say(
|
||
|
response.ok
|
||
|
? `:nya-n: < ${await response.text()}`
|
||
|
: `:nya-n: < がんばったけど ${ip} よくわからんかったにゃん`
|
||
|
);
|
||
|
}
|
||
|
];
|