From ae229f9af3610a90e3ccb246b10ad8bd3fba8d6f Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Sun, 10 May 2026 23:13:18 +0700 Subject: [PATCH] refactor: forward text as-is, drop request-metadata prefix Enrichment (IP, UA, geo, timezone, URL, timestamp) is now handled by miti-loki. miti-telegram becomes a minimal text-passthrough so callers can format messages however they want without the worker mutating them. --- README.md | 2 +- index.js | 39 +-------------------------------------- 2 files changed, 2 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index f89df20..88be5de 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ curl -X POST https://miti-telegram.miti99.workers.dev/ \ `application/x-www-form-urlencoded` (`text=...`) is also accepted. Responses are CORS-permissive (`Access-Control-Allow-Origin: *`). -The worker prepends request metadata (IP, geo, UA, timestamp) to every message before forwarding to Telegram — that's expected, not an info leak (it's *your* Telegram). +The worker forwards `text` to Telegram as-is (no prepended metadata). For request enrichment (IP, UA, geo, etc.) use [miti-loki](https://github.com/tiennm99/miti-loki) instead. ### For AI agents / Claude Code routines diff --git a/index.js b/index.js index 54177fa..c84e7c0 100644 --- a/index.js +++ b/index.js @@ -50,42 +50,6 @@ export default { }); } - // Collect client request information - const clientIP = request.headers.get('CF-Connecting-IP') || - request.headers.get('X-Forwarded-For') || - request.headers.get('X-Real-IP') || - 'Unknown'; - - const userAgent = request.headers.get('User-Agent') || 'Unknown'; - const country = request.cf?.country || 'Unknown'; - const city = request.cf?.city || 'Unknown'; - const region = request.cf?.region || 'Unknown'; - const latitude = request.cf?.latitude || 'Unknown'; - const longitude = request.cf?.longitude || 'Unknown'; - const timezone = request.cf?.timezone || 'Unknown'; - const url = request.url || 'Unknown'; - const timestamp = new Date().toISOString(); - - // Format the message with request information - const hasCoordinates = latitude !== 'Unknown' && longitude !== 'Unknown'; - const mapLink = hasCoordinates - ? `https://www.google.com/maps?q=${latitude},${longitude}` - : null; - - const requestInfo = `IP: ${clientIP} 🔍 -Browser: ${userAgent} -Country: ${country} -Region: ${region} -City: ${city} -Coordinates: ${latitude}, ${longitude}${mapLink ? ` 📍` : ''} -Timezone: ${timezone} -Timestamp: ${timestamp} -Original text:`; - - const formattedMessage = `${requestInfo} - -${text}`; - const telegramToken = env.TELEGRAM_TOKEN; const telegramChatId = env.TELEGRAM_CHAT_ID; @@ -101,8 +65,7 @@ ${text}`; const telegramUrl = `https://api.telegram.org/bot${telegramToken}/sendMessage`; const telegramPayload = { chat_id: telegramChatId, - text: formattedMessage, - parse_mode: 'HTML' + text, }; const telegramResponse = await fetch(telegramUrl, {