This project is a Telegram bot designed to provide detailed information about a given IP address (IPv4 or IPv6). The bot leverages the IPInfo.io API to fetch geographical and network-related data. It is built to run seamlessly on Cloudflare Workers, making it a cost-effective and scalable solution.
- Accepts IP addresses (both IPv4 and IPv6) from users.
- Returns detailed information about the IP address, including:
- City
- Region
- Country
- Location (Latitude and Longitude)
- Organization
- Postal Code
- Timezone
- Supports
/start
command to provide an introduction to the bot. - Provides meaningful error messages for invalid or unrecognized inputs.
- Leverages the IPInfo.io API to fetch accurate and up-to-date IP data.
- The bot receives messages from users via Telegram.
- It validates the input to ensure it matches an IP address format.
- If valid, it queries the IPInfo.io API to retrieve information about the IP.
- The bot formats the data and sends it back to the user in a readable format.
This bot is optimized for deployment on Cloudflare Workers. Here's why Cloudflare Workers is a great fit:
- Free Tier: Cloudflare Workers offers a generous free tier, making it a cost-effective hosting option.
- Global Edge Network: Responses are served with low latency thanks to Cloudflare's global network.
- Ease of Deployment: The bot's code is written in JavaScript, which integrates seamlessly with Cloudflare Workers.
git clone https://github.com/MrDevAnony/IPinfoBot.git
cd IPinfoBot
- TELEGRAM_API_TOKEN: Your Telegram bot token.
- IPINFO_TOKEN: Your token from IPInfo.io.
- install Wrangler CLI:
npm install -g wrangler
- Authenticate with Cloudflare:
wrangler login
- Deploy the bot:
wrangler publish
Note the generated Worker URL and set it as your bot's webhook using the following command:
curl -X POST "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook?url=<YOUR_WORKER_URL>"
Done!
- Free Plan: Cloudflare Workers provides 100,000 free requests per day.
- Scalability: Automatically scales with traffic.
- Low Latency: Serves requests from the edge, ensuring fast responses globally.
- No Server Management: Eliminate the need for managing servers or infrastructure.