Skip to content

MrDevAnony/IPinfoBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Telegram Bot for IP Information Lookup

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.

Features

  • 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.

How It Works

  1. The bot receives messages from users via Telegram.
  2. It validates the input to ensure it matches an IP address format.
  3. If valid, it queries the IPInfo.io API to retrieve information about the IP.
  4. The bot formats the data and sends it back to the user in a readable format.

Deployment on Cloudflare Workers

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.

Installation and Deployment

1. Clone the Repository

git clone https://github.com/MrDevAnony/IPinfoBot.git
cd IPinfoBot

2. Set up environment variables for security:

  1. TELEGRAM_API_TOKEN: Your Telegram bot token.
  2. IPINFO_TOKEN: Your token from IPInfo.io.

3. Deploy to Cloudflare Workers

  1. install Wrangler CLI:
npm install -g wrangler
  1. Authenticate with Cloudflare:
wrangler login
  1. 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!


Cloudflare Workers Benefits

  • 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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published