https://github.com/mrdevanony/ipinfobot
https://github.com/mrdevanony/ipinfobot
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mrdevanony/ipinfobot
- Owner: MrDevAnony
- License: mit
- Created: 2025-01-05T17:02:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-05T17:52:21.000Z (over 1 year ago)
- Last Synced: 2025-05-21T20:11:42.932Z (about 1 year ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://ipinfo.io/) API to fetch geographical and network-related data. It is built to run seamlessly on [Cloudflare Workers](https://workers.cloudflare.com/), 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](https://ipinfo.io/) 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
```bash
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](https://developers.cloudflare.com/workers/wrangler/):
```bash
npm install -g wrangler
```
2. Authenticate with Cloudflare:
```bash
wrangler login
```
3. Deploy the bot:
```bash
wrangler publish
```
Note the generated Worker URL and set it as your bot's webhook using the following command:
```bash
curl -X POST "https://api.telegram.org/bot/setWebhook?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.
---