✨IP Address Information Telegram Bot Code
📚 Bjs:
// Command: /getIP
Bot.sendMessage("Please enter the IP address you want to look up:");
// Run the command `/processIP` after the user inputs the IP address
Bot.runCommand("/processIP");
👁️🗨️ Command: /processIP
Wait For Answer ✅
📚 Bjs:
// Command: /processIP
var ip = message; // The user's input (IP address)
if (!ip || !ip.match(/^(\d{1,3}\.){3}\d{1,3}$/)) {
// Validate the input: Check if it matches an IP address pattern
Bot.sendMessage("Invalid IP address. Please enter a valid IP address.");
Bot.runCommand("/processIP");
return;
}
// Making an HTTP request to ip-api.com
HTTP.get({
url: "http://ip-api.com/json/" + ip,
success: "/onIPInfo",
error: "/onError"
});
👁️🗨️Command: /onIPInfo
📚Bjs:
var response = JSON.parse(content);
if (response.status == "fail") {
Bot.sendMessage("Error: " + response.message);
return;
}
var message = "IP Address Info:\n";
message += "IP: " + response.query + "\n";
message += "Country: " + response.country + " (" + response.countryCode + ")\n";
message += "Region: " + response.regionName + "\n";
message += "City: " + response.city + "\n";
message += "ZIP: " + response.zip + "\n";
message += "Latitude: " + response.lat + "\n";
message += "Longitude: " + response.lon + "\n";
message += "ISP: " + response.isp + "\n";
message += "Org: " + response.org + "\n";
message += "AS: " + response.as + "\n";
Bot.sendMessage(message);
👁️🗨️Command: /onError
📚Bjs:
// Command: /onError
Bot.sendMessage("An error occurred while retrieving IP information. Please try again later.");
❤️ OWNED BY @ ❤️
📚 Bjs:
// Command: /getIP
Bot.sendMessage("Please enter the IP address you want to look up:");
// Run the command `/processIP` after the user inputs the IP address
Bot.runCommand("/processIP");
👁️🗨️ Command: /processIP
Wait For Answer ✅
📚 Bjs:
// Command: /processIP
var ip = message; // The user's input (IP address)
if (!ip || !ip.match(/^(\d{1,3}\.){3}\d{1,3}$/)) {
// Validate the input: Check if it matches an IP address pattern
Bot.sendMessage("Invalid IP address. Please enter a valid IP address.");
Bot.runCommand("/processIP");
return;
}
// Making an HTTP request to ip-api.com
HTTP.get({
url: "http://ip-api.com/json/" + ip,
success: "/onIPInfo",
error: "/onError"
});
👁️🗨️Command: /onIPInfo
📚Bjs:
var response = JSON.parse(content);
if (response.status == "fail") {
Bot.sendMessage("Error: " + response.message);
return;
}
var message = "IP Address Info:\n";
message += "IP: " + response.query + "\n";
message += "Country: " + response.country + " (" + response.countryCode + ")\n";
message += "Region: " + response.regionName + "\n";
message += "City: " + response.city + "\n";
message += "ZIP: " + response.zip + "\n";
message += "Latitude: " + response.lat + "\n";
message += "Longitude: " + response.lon + "\n";
message += "ISP: " + response.isp + "\n";
message += "Org: " + response.org + "\n";
message += "AS: " + response.as + "\n";
Bot.sendMessage(message);
👁️🗨️Command: /onError
📚Bjs:
// Command: /onError
Bot.sendMessage("An error occurred while retrieving IP information. Please try again later.");
❤️ OWNED BY @ ❤️