-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipstash.js
43 lines (41 loc) · 1.26 KB
/
ipstash.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
41
42
43
let url = "http://ip-api.com/json/?fields=8450015&lang=VN"
$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: "Thông tin",
content: `IP:${query}\nNhà cung cấp:${isp}\nASN:${as}\n🌍Quốc gia/Khu vực:${emoji}${country}\nThành phố:${city}\nMúi giờ:${timezone}\n
Vĩ độ và Kinh độ:${lon},${lat}\nTiền tệ:${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)])
);
}