Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions src/kruh.deno.ts
Original file line number Diff line number Diff line change
@@ -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 =
Expand Down Expand Up @@ -30,7 +29,7 @@ export async function getDinosaurPlaycount(): Promise<number | null> {
},
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",
});
Expand Down
64 changes: 41 additions & 23 deletions src/tg/bot.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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:

Expand All @@ -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}`);

Expand All @@ -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)}...`);

Expand Down
2 changes: 1 addition & 1 deletion src/tg/init.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!!",
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/tg/utils.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
Loading