mirror of
https://github.com/tiennm99/miti-telegram.git
synced 2026-10-11 03:13:41 +00:00
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.
This commit is contained in:
1 parent
e9a48f2e60
commit
ae229f9af3
2 files changed
+2
-39
No files matched your search
@@ -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
|
||||
|
||||
|
||||
@@ -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 = `<b>IP</b>: <code>${clientIP}</code> <a href="https://ipinfo.io/${clientIP}">🔍</a>
|
||||
<b>Browser</b>: <code>${userAgent}</code>
|
||||
<b>Country</b>: <code>${country}</code>
|
||||
<b>Region</b>: <code>${region}</code>
|
||||
<b>City</b>: <code>${city}</code>
|
||||
<b>Coordinates</b>: <code>${latitude}, ${longitude}</code>${mapLink ? ` <a href="${mapLink}">📍</a>` : ''}
|
||||
<b>Timezone</b>: <code>${timezone}</code>
|
||||
<b>Timestamp</b>: <code>${timestamp}</code>
|
||||
<b>Original text</b>:`;
|
||||
|
||||
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, {
|
||||
|
||||
Reference in new issue
Block a user