Skip to content

Instantly share code, notes, and snippets.

@Aqendo
Created December 5, 2022 17:16
Show Gist options
  • Save Aqendo/780caa4e7837825c9c21bfc98b5bda28 to your computer and use it in GitHub Desktop.
Save Aqendo/780caa4e7837825c9c21bfc98b5bda28 to your computer and use it in GitHub Desktop.
i am not good at js
async function handleRequest(request) {
if (!(request.method === "POST")) return new Response("OK")
const payload = await request.json()
// Getting the POST request JSON payload
if (!('inline_query' in payload)) return new Response("OK")
const i_d = payload.inline_query.id
let resp = new Response(JSON.stringify({
"method": "answerInlineQuery",
"inline_query_id": i_d,
"results": JSON.stringify([{
"type": "article",
"id": "kek",
"title": "/BLUE /TEXT\n/MUST /CLICK\n/I /AM /A /STUPID /ANIMAL /THAT /IS /ATTRACTED /TO /COLORS",
"input_message_content": {
"message_text": "/BLUE /TEXT\n/MUST /CLICK\n/I /AM /A /STUPID /ANIMAL /THAT /IS /ATTRACTED /TO /COLORS"
}
}])
}))
resp.headers.append("content-type", "application/json")
return resp
}
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment