Skip to content

Commit

Permalink
fix domeny, detect edited messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mvolfik committed Oct 18, 2024
1 parent 3e75667 commit 7bf4070
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"deno.enable": true,
"deno.unstable": false
"deno.unstable": false,
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
}
}
17 changes: 13 additions & 4 deletions tgbot.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ async function domeny() {
(a) =>
a.auction_from.split("T")[0] === new Date().toISOString().split("T")[0],
)
.map((x) => x.item_title);
.map((x) => x.item_title)
.map((x) => x.replaceAll(".", "\\."));
x.sort();
x.sort((a, b) => a.length - b.length);
while (x.length > 0) {
const chunk = x.splice(0, 50);
const webArchiveLinks = chunk.map((l) =>
`[${l}](https://web.archive.org/web/*/${l})`
const webArchiveLinks = chunk.map(
(l) => `[${l}](https://web.archive.org/web/${l})`,
);
await tgCall({
text: webArchiveLinks.join("\n"),
Expand Down Expand Up @@ -164,7 +165,12 @@ export async function init() {
{
url: `https://${DOMAIN}${webhookPath}`,
secret_token: webhookUrlToken,
allowed_updates: ["message", "callback_query", "inline_query"],
allowed_updates: [
"message",
"callback_query",
"inline_query",
"edited_message",
],
},
"setWebhook",
);
Expand Down Expand Up @@ -211,6 +217,9 @@ export async function handleRequest(e: Deno.RequestEvent) {
async function processTgUpdate(data: any) {
if ("callback_query" in data) return await handleCallbackQuery(data);
if ("inline_query" in data) return await handleInlineQuery(data);
if ("edited_message" in data) {
data.message = data.edited_message;
}

const text = data?.message?.text ?? data?.message?.caption;
if (typeof text !== "string") return;
Expand Down

0 comments on commit 7bf4070

Please sign in to comment.