From 0d9e00a67aa97bb499abcb53e42caa580d22af27 Mon Sep 17 00:00:00 2001 From: WIPocket Date: Sat, 25 Jul 2026 17:09:45 +0200 Subject: [PATCH] =?UTF-8?q?to=20byl=20Mat=C4=9Bj,=20ale=20ja=20v=C3=ADm=20?= =?UTF-8?q?kter=C3=A1=20je=20kter=C3=A1,=20he=C4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/kruh.deno.ts | 5 ++-- src/tg/bot.deno.ts | 64 ++++++++++++++++++++++++++++---------------- src/tg/init.deno.ts | 2 +- src/tg/utils.deno.ts | 2 +- 4 files changed, 45 insertions(+), 28 deletions(-) diff --git a/src/kruh.deno.ts b/src/kruh.deno.ts index a06d191..1a26e33 100644 --- a/src/kruh.deno.ts +++ b/src/kruh.deno.ts @@ -1,7 +1,6 @@ export const DINOSAUR_UID = "c838e77e8a599aba7d0b"; -const SPOTIFY_QUERY_URL = - "https://api-partner.spotify.com/pathfinder/v2/query"; +const SPOTIFY_QUERY_URL = "https://api-partner.spotify.com/pathfinder/v2/query"; const SPOTIFY_AUTHORIZATION = "Bearer BQCWnlfP-dGQG8eRiFRsdx0zBI_OHkgbjJ_FymeSGZaTuqdiVhMfs_YXgmwt7BoY_psA-up3vuHxTO602Yzob5LoqclAVHt11FHGuPPRXkbbQjX7QrrUulzSbom06S4_6H1jPyQeOKA"; const SPOTIFY_CLIENT_TOKEN = @@ -30,7 +29,7 @@ export async function getDinosaurPlaycount(): Promise { }, referrer: "https://open.spotify.com/", body: - "{\"variables\":{\"uri\":\"spotify:artist:7wwkwCP5b0waa5bhpZCDPq\",\"locale\":\"\",\"preReleaseV2\":false},\"operationName\":\"queryArtistOverview\",\"extensions\":{\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"7f86ff63e38c24973a2842b672abe44c910c1973978dc8a4a0cb648edef34527\"}}}", + '{"variables":{"uri":"spotify:artist:7wwkwCP5b0waa5bhpZCDPq","locale":"","preReleaseV2":false},"operationName":"queryArtistOverview","extensions":{"persistedQuery":{"version":1,"sha256Hash":"7f86ff63e38c24973a2842b672abe44c910c1973978dc8a4a0cb648edef34527"}}}', method: "POST", mode: "cors", }); diff --git a/src/tg/bot.deno.ts b/src/tg/bot.deno.ts index 63fbaf3..fdb2908 100644 --- a/src/tg/bot.deno.ts +++ b/src/tg/bot.deno.ts @@ -248,9 +248,11 @@ export async function* handleTgUpdate(data: any) { yield await tgCall( { chat_id: data.message.chat.id, - video_note: Math.random() < 0.5 + video_note: Math.random() < 0.4 ? "DQACAgQAAxkDAAM8ZWhhSjCXOdVCv7a8SkikjCDwEH4AAiQSAAKXPEhTuYZAGfYG_KwzBA" - : "DQACAgQAAx0CYbOIYwABAZOgaSF5TvqBIZtJAkkgCyJa5lPTpvUAAmkaAAKkFxBRMvxu2BMBa4c2BA", + : Math.random() < 0.5 + ? "DQACAgQAAx0CYbOIYwABAZOgaSF5TvqBIZtJAkkgCyJa5lPTpvUAAmkaAAKkFxBRMvxu2BMBa4c2BA" + : "DQACAgQAAx0CYbOIYwABAeQHamS3gT0UutJXb9NKjSz3a6rIOD8AAn4hAAI9miFT94mag0zwGJA9BA", }, "sendVideoNote", ); @@ -495,7 +497,8 @@ Be grateful for your abilities and your incredible success and your considerable }); } - if ( text.toLowerCase().includes("kowalski") && + if ( + text.toLowerCase().includes("kowalski") && data.message.chat.id === MAIN_CHAT_ID ) { yield* handleAnalysis(data, text, 30); @@ -808,11 +811,16 @@ async function* reportProcessResult( `](https://${DOMAIN}/tgweb/${id}) \\(exit code ${exitCode}, ${length} bytes\\)\\. Set Content\\-Type with \`/settype ${id} mime/type\``; } - yield await tgCall({ - reply_to_message_id, - parse_mode: "MarkdownV2", - text, - }, "sendMessage", 0, true); + yield await tgCall( + { + reply_to_message_id, + parse_mode: "MarkdownV2", + text, + }, + "sendMessage", + 0, + true, + ); } async function handleCallbackQuery(data: any) { @@ -876,9 +884,12 @@ async function* handleInlineQuery(data: any) { async function* handleAnalysis(data: any, text: string, n: number) { const recent = messageHistory.slice(-n); - const chatText = recent.map((m, i) => `#${i + 1} ${m.from}: ${m.text}`).join("\n\n"); + const chatText = recent.map((m, i) => `#${i + 1} ${m.from}: ${m.text}`).join( + "\n\n", + ); - let prompt = `Uživatel spustil příkaz "kowalski". Jsi Kowalski z Tučňáků z Madagaskaru: hyperanalytický, taktický, mírně přehnaně sebevědomý a dramaticky zaujatý dešifrováním sociálního chaosu. + let prompt = + `Uživatel spustil příkaz "kowalski". Jsi Kowalski z Tučňáků z Madagaskaru: hyperanalytický, taktický, mírně přehnaně sebevědomý a dramaticky zaujatý dešifrováním sociálního chaosu. Zde je přepis posledních ${n} zpráv ze skupinového chatu: @@ -896,19 +907,22 @@ Napiš MAXIMÁLNĚ TŘI (3) VĚTY. Buď stručný. Nevypadávej z role. Nevysvě } try { - const resp = await fetch("https://api.juan.bilej.monster/v1/chat/completions", { - method: "POST", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${LLM_KEY}`, + const resp = await fetch( + "https://api.juan.bilej.monster/v1/chat/completions", + { + method: "POST", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${LLM_KEY}`, + }, + body: JSON.stringify({ + model: "qwen3-27b", + messages: [{ role: "user", content: prompt }], + max_tokens: 2048, + chat_template_kwargs: { enable_thinking: false }, + }), }, - body: JSON.stringify({ - model: "qwen3-27b", - messages: [{ role: "user", content: prompt }], - max_tokens: 2048, - chat_template_kwargs: { enable_thinking: false }, - }), - }); + ); console.log(`Juan API response status: ${resp.status}`); @@ -925,7 +939,11 @@ Napiš MAXIMÁLNĚ TŘI (3) VĚTY. Buď stručný. Nevypadávej z role. Nevysvě const json = await resp.json(); const msg = json.choices?.[0]?.message; - const text = (msg?.content || msg?.reasoning_content || "juan ded (no content)").slice(0, 4000); + const text = + (msg?.content || msg?.reasoning_content || "juan ded (no content)").slice( + 0, + 4000, + ); console.log(`Juan reply: ${text.slice(0, 100)}...`); diff --git a/src/tg/init.deno.ts b/src/tg/init.deno.ts index 6a6d0c3..d7ce0e4 100644 --- a/src/tg/init.deno.ts +++ b/src/tg/init.deno.ts @@ -317,7 +317,7 @@ export async function init() { dinosaurMillionAnnounced = true; await tgCall({ chat_id: MAIN_CHAT_ID, - text: 'Dinosaur má milion na Spotify!!', + text: "Dinosaur má milion na Spotify!!", }); } }); diff --git a/src/tg/utils.deno.ts b/src/tg/utils.deno.ts index 7765c19..adf5806 100644 --- a/src/tg/utils.deno.ts +++ b/src/tg/utils.deno.ts @@ -50,7 +50,7 @@ const blabla = " bla bla"; export const shutUpState = { shut: false, - up: ([] as ((value: any) => void)[]), + up: [] as ((value: any) => void)[], timeout: -1, };