Skip to content

Commit 88f4049

Browse files
committed
bug fixes and improvements
1 parent 0d9e000 commit 88f4049

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

tgbot.deno.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ export async function init() {
193193
);
194194

195195
await tgCall({
196-
text:
197-
"prokop hazejici vlastovku",
196+
text: "prokop hazejici vlastovku",
198197
});
199198

200199
postGeohash();
@@ -246,7 +245,7 @@ async function processTgUpdate(data: any) {
246245
}
247246

248247
async function* handleTgUpdate(data: any) {
249-
const {ok} = data;
248+
const { ok } = data;
250249
data.message ??= data.result;
251250
if ("callback_query" in data) return yield* handleCallbackQuery(data);
252251
if ("inline_query" in data) return yield* handleInlineQuery(data);
@@ -396,7 +395,7 @@ Be grateful for your abilities and your incredible success and your considerable
396395
data.message.reply_to_message,
397396
null,
398397
2,
399-
)
398+
).replaceAll("\\", "\\\\")
400399
}\n\`\`\``,
401400
});
402401
}
@@ -548,7 +547,7 @@ Be grateful for your abilities and your incredible success and your considerable
548547
text:
549548
`Zjištěno porušení pravidel uživatelem ${data.message.from.first_name}, tento incident byl zaznamenán. Příště prosím přidejte do zpávy tento disclaimer:\n\n${disclaimer}`,
550549
});
551-
if(ok) {
550+
if (ok) {
552551
yield await tgCall({
553552
chat_id: data.message.chat.id,
554553
text: "oh shit sry mb",
@@ -559,7 +558,6 @@ Be grateful for your abilities and your incredible success and your considerable
559558
entities: data.message.entities,
560559
});
561560
}
562-
break;
563561
}
564562
}
565563
}
@@ -800,12 +798,12 @@ async function* sticekrThis(orig_msg: any): Promise<string | null> {
800798
},
801799
"getFile",
802800
);
803-
if (!data.ok) return "telegrams a hoe2";
801+
if (!data.ok) return "telegrams a hoe: " + JSON.stringify(data);
804802

805803
const resp2 = await fetch(
806804
`https://api.telegram.org/file/bot${token}/${data.result.file_path}`,
807805
);
808-
if (!resp2.ok) return "telegram cdn is a hoe";
806+
if (!resp2.ok) return "telegram cdn is a hoe: " + await resp2.text();
809807

810808
const fileName = await Deno.makeTempFile();
811809
await Deno.writeFile(fileName, resp2.body!);
@@ -833,15 +831,17 @@ async function* sticekrThis(orig_msg: any): Promise<string | null> {
833831
body,
834832
},
835833
);
836-
if (!resp3.ok) return "skill issue";
834+
if (!resp3.ok) return "skill issue: " + await resp3.text();
837835

838836
const data4 = await tgCall(
839837
{
840838
name: STICEKR_SET_NAME,
841839
},
842840
"getStickerSet",
843841
);
844-
if (!data4.ok) return "i ran out of error message ideas";
842+
if (!data4.ok) {
843+
return "i ran out of error message ideas: " + JSON.stringify(resp4);
844+
}
845845
const sticekrId = data4.result.stickers.at(-1).file_id;
846846
if (!sticekrId) return "i ran out of error message ideas the most";
847847

@@ -854,7 +854,10 @@ async function* sticekrThis(orig_msg: any): Promise<string | null> {
854854
);
855855
yield resp5;
856856

857-
if (!resp5.ok) return "actually it succeeded but i failed to send it";
857+
if (!resp5.ok) {
858+
return "actually it succeeded but i failed to send it: " +
859+
JSON.stringify(resp5);
860+
}
858861

859862
return null;
860863
}

0 commit comments

Comments
 (0)