MCPcopy Create free account
hub / github.com/cmliu/WorkerVless2sub / sendMessage

Function sendMessage

_worker.js:223–248  ·  view source on GitHub ↗
(type, ip, add_data = "")

Source from the content-addressed store, hash-verified

221}
222
223async 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
250async function nginx() {
251 const text = `

Callers 1

fetchFunction · 0.85

Calls 1

fetchFunction · 0.85

Tested by

no test coverage detected