-
Notifications
You must be signed in to change notification settings - Fork 215
/
ip-api.js
40 lines (40 loc) · 1.25 KB
/
ip-api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
let url = "http://ip-api.com/json/?fields=8450015&lang=zh-CN"
$httpClient.get(url, function(error, response, data){
let jsonData = JSON.parse(data)
let query =jsonData.query
let isp =jsonData.isp
let as =jsonData.as
let country =jsonData.country
let city =jsonData.city
let timezone =jsonData.timezone
let lon =jsonData.lon
let lat =jsonData.lat
let currency =jsonData.currency
let emoji = getFlagEmoji(jsonData.countryCode)
const params = getParams($argument);
body = {
title: "节点信息",
content: `🗺️IP:${query}\n🖥️ISP:${isp}\n#️⃣ASN:${as}\n🌍国家/地区:${emoji}${country}\n🏙城市:${city}\n🕗时区:${timezone}\n📍经纬度:${lon},${lat}\n🪙货币:${currency}`,
icon: params.icon,
"icon-color": params.color
}
$done(body);
});
function getFlagEmoji(countryCode) {
if (countryCode.toUpperCase() == 'TW') {
countryCode = 'CN'
}
const codePoints = countryCode
.toUpperCase()
.split('')
.map(char => 127397 + char.charCodeAt())
return String.fromCodePoint(...codePoints)
}
function getParams(param) {
return Object.fromEntries(
$argument
.split("&")
.map((item) => item.split("="))
.map(([k, v]) => [k, decodeURIComponent(v)])
);
}