Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions worker/worker-with-TG-tracker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
addEventListener('fetch', (event) => {
event.respondWith(handleRequest(event.request));
});

async function handleRequest(request) {
const url = new URL(request.url);
const id = url.searchParams.get('id');

const urlList = await fetch(
'https://gist.githubusercontent.com/xxxloperaxxz/3xxx1971d7xxxx72c7axxx85/raw/links.txt'
)
.then((response) => response.text())
.then((text) => text.split('\n'))
.catch((error) => {
return new Response(error, { status: 500 });
});

const redirectURL = urlList.find((u) => u.split(' ')[0] === id);
if (!redirectURL) {
return new Response('Invalid ID', { status: 404 });
}

await fetch(
`https://api.telegram.org/bot000000000:XXxxxxx-XXXXXXXXXXXXXXXXXxxxxXXXXXXX/sendMessage?chat_id=00000000&text=Someone%20is%20Requesting%20File520ID%20${id}`
).catch((error) => {
console.error('Error sending POST request:', error);
});

return Response.redirect(redirectURL.split(' ')[1], 301);
}