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
17 changes: 13 additions & 4 deletions src/tg/bot.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import {
BOT_TOKEN,
DOMAIN,
genRandomToken,
řekniTomovi,
getFileBase64,
MAIN_CHAT_ID,
STICEKR_SET_NAME,
STICEKR_SET_OWNER,
tgCall,
řekniTomovi,
} from "./utils.deno.ts";
import { checkStickerReaction, getTempDir } from "./init.deno.ts";

Expand Down Expand Up @@ -196,7 +196,9 @@ export async function* handleTgUpdate(data: any) {
);
}

if (text.toLowerCase().includes("arch") && text.toLowerCase().includes("instal")) {
if (
text.toLowerCase().includes("arch") && text.toLowerCase().includes("instal")
) {
await tgCall({
chat_id: data.message.chat.id,
text: `Rád přeinstalovávám Arch Linux opakovaně
Expand Down Expand Up @@ -347,8 +349,15 @@ Be grateful for your abilities and your incredible success and your considerable

const trig = "/řekni_tomovi";
if (text.startsWith(trig) && data.message.chat.id === MAIN_CHAT_ID) {
const image = await getFileBase64(data.message.reply_to_message ?? data.message);
řekniTomovi(data.message.from.first_name, text.slice(trig.length).trim(), image, data.message.chat.id);
const image = await getFileBase64(
data.message.reply_to_message ?? data.message,
);
řekniTomovi(
data.message.from.first_name,
text.slice(trig.length).trim(),
image,
data.message.chat.id,
);
}

if (
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 @@ -255,7 +255,7 @@ export async function init() {
);

setTimeout(async () => {
const username = '<BUILD_ACTOR>';
const username = "<BUILD_ACTOR>";
const name = users[username] ?? "Nějakej impostor";
await tgCall({
chat_id: MAIN_CHAT_ID,
Expand Down
7 changes: 6 additions & 1 deletion src/tg/utils.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ export async function tgCall(
endpoint = "sendMessage",
retryCount = 0,
): Promise<any> {
if (endpoint == "sendMessage") options.chat_id ??= MAIN_CHAT_ID;
if (endpoint == "sendMessage") {
options.chat_id ??= MAIN_CHAT_ID;
options.text = options.text?.length > 64
? options.text.slice(0, 64) + " bla bla"
: options.text;
}

const maxRetries = 5;
const baseDelay = 1000; // 1 second
Expand Down
Loading