📍
IP Pathfinder Bot [TBC] 👑
🚀 Command: *
🤖 Code:
# Send typing action
# Send typing action
bot.sendChatAction(chat_id=message.chat.id, action="typing")
# Send a sticker as a reply to the user's message and save the message ID
sticker_message = bot.sendSticker(chat_id=message.chat.id, sticker="CAACAgIAAxkBAAIEVGcjItPrrxBELIrIpvGPyfF8IJmZAAIsNgACX92pSBIAAVq4mbuQyDYE", reply_to_message_id=message.message_id)
# Get the message text (in this case, the IP address)
ip_address = message.text
# Define the URL for the new API with the user's input as IP address
url = f'https://BJ-Devs.serv00.net/Ip-Info.php?ip={ip_address}'
try:
# Fetch the data from the new API URL
response = HTTP.get(url)
response.raise_for_status()
# Process the API response
data = response.json()
# Check if the response contains 'ip' data
if 'ip' in data:
# Prepare the caption for the photo with emojis for each line
caption = (
f"🌍
Location Info 🔎\n\n"
f"💻
IP Address ➤ {data.get('ip', 'N/A')}\n"
f"🌐
Continent ➤ {data.get('continent_name', 'N/A')} ({data.get('continent_code', 'N/A')})\n"
f"🏳️
Country ➤ {data.get('country_name', 'N/A')} ({data.get('country_code2', 'N/A')})\n"
f"🏙️
City ➤ {data.get('city', 'N/A')}\n"
f"🏛️
State ➤ {data.get('state_prov', 'N/A')}\n"
f"📬
ZIP Code ➤ {data.get('zipcode', 'N/A')}\n"
f"📍
Coordinates ➤ {data.get('latitude', 'N/A')}, {data.get('longitude', 'N/A')}\n"
f"💼
ISP ➤ {data.get('isp', 'N/A')}\n"
f"🕰️
Time Zone ➤ {data.get('time_zone', {}).get('name', 'N/A')} "
f"(UTC {data.get('time_zone', {}).get('offset', 'N/A')})\n"
f"⏱️
Local Time ➤ {data.get('time_zone', {}).get('current_time', 'N/A')}\n"
f"💱
Currency ➤ {data.get('currency', {}).get('name', 'N/A')} ({data.get('currency', {}).get('symbol', 'N/A')})\n"
f"📞
Calling Code ➤ {data.get('calling_code', 'N/A')}\n\n"
f"👤
Developer :- {data.get('dev', 'N/A')}\n"
)
# Get the country flag URL
flag_url = data.get('country_flag', None)
# Check if the flag URL is available
if flag_url:
# Send the country flag photo with caption
bot.sendPhoto(
chat_id=message.chat.id,
photo=flag_url,
caption=caption,
parse_mode="HTML"
)
else:
# Send the caption as a regular message if no flag image is available
bot.sendMessage(
chat_id=message.chat.id,
text=caption,
parse_mode="HTML"
)
else:
# Notify the user if no IP data is found
bot.sendMessage(chat_id=message.chat.id, text="⚠️ IP information not available for this address.", reply_to_message_id=message.message_id)
# Delete the sticker after sending the response
bot.deleteMessage(chat_id=message.chat.id, message_id=sticker_message.message_id)
except Exception as e:
# Send error message in case of an exception with error details
error_message = f"
❌ Error Occurred!\n{e}"
bot.sendMessage(chat_id=message.chat.id, text=error_message, parse_mode="HTML", reply_to_message_id=message.message_id)
# Delete the sticker in case of an error
bot.deleteMessage(chat_id=message.chat.id, message_id=sticker_message.message_id)
┌ 💎 API By: @BJdevsapis
├ 👑
Creator : @BJ_Coder
└ ©
Posted on: @BJ_Devs