| 221 | } |
| 222 | |
| 223 | async function sendMessage(type, ip, add_data = "") { |
| 224 | if (!BotToken || !ChatID) return; |
| 225 | |
| 226 | try { |
| 227 | let msg = ""; |
| 228 | const response = await fetch(`http://ip-api.com/json/${ip}?lang=zh-CN`); |
| 229 | if (response.ok) { |
| 230 | const ipInfo = await response.json(); |
| 231 | msg = `${type}\nIP: ${ip}\n国家: ${ipInfo.country}\n<tg-spoiler>城市: ${ipInfo.city}\n组织: ${ipInfo.org}\nASN: ${ipInfo.as}\n${add_data}`; |
| 232 | } else { |
| 233 | msg = `${type}\nIP: ${ip}\n<tg-spoiler>${add_data}`; |
| 234 | } |
| 235 | |
| 236 | const url = `https://api.telegram.org/bot${BotToken}/sendMessage?chat_id=${ChatID}&parse_mode=HTML&text=${encodeURIComponent(msg)}`; |
| 237 | return fetch(url, { |
| 238 | method: 'GET', |
| 239 | headers: { |
| 240 | 'Accept': 'text/html,application/xhtml+xml,application/xml;', |
| 241 | 'Accept-Encoding': 'gzip, deflate, br', |
| 242 | 'User-Agent': 'Mozilla/5.0 Chrome/90.0.4430.72' |
| 243 | } |
| 244 | }); |
| 245 | } catch (error) { |
| 246 | console.error('Error sending message:', error); |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | async function nginx() { |
| 251 | const text = ` |