Skip to content

Commit

Permalink
Fixed editor generator in telegram
Browse files Browse the repository at this point in the history
  • Loading branch information
Azarattum committed Apr 21, 2024
1 parent b697505 commit 09c84c1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
8 changes: 6 additions & 2 deletions apps/core/network/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { merge, pick } from "@amadeus-music/util/object";
import { Readable, type Writable } from "node:stream";
import { gretch, type GretchOptions } from "gretchen";
import tls, { type SecureVersion } from "node:tls";
import type { Context } from "../plugin/types";
import { errorify } from "libfun/utils/error";
import type { Struct } from "superstruct";
import { async, context } from "libfun";
import { Readable } from "node:stream";
import { pools } from "../event/pool";
import { Form } from "./form";

Expand All @@ -20,7 +20,11 @@ type FetchOptions = {
tls?: SecureVersion;
form?: Record<
string,
string | number | (string | number)[] | [Readable, string] | undefined
| string
| number
| (string | number)[]
| [Readable | Writable, string]
| undefined
>;
};

Expand Down
18 changes: 9 additions & 9 deletions plugins/telegram/api/reply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function* queue(
notifier: () => void,
name: string,
tracks: Track[],
group = true
group = true,
) {
let done = false;
const ping = (notifier(), setInterval(notifier, 3000));
Expand All @@ -56,13 +56,13 @@ function* queue(
track,
mode: markdown(),
markup: !group ? menu(track.id) : undefined,
}).then((x) => (setTimeout(() => done || notifier(), 10), x))
}).then((x) => (setTimeout(() => done || notifier(), 10), x)),
);
}
yield* yield* async(
Promise.allSettled(promises).then((x) =>
x.map((x) => (x.status === "rejected" ? 0 : +x.value))
)
x.map((x) => (x.status === "rejected" ? 0 : +x.value)),
),
);
done = true;
}
Expand All @@ -73,21 +73,21 @@ function* reply(chat: number, params: Message) {
params.file = yield* async(
persistence()
.settings.extract(params.track.id.toString())
.then(null, () => undefined)
.then(null, () => undefined),
);
}

const { result } = yield* "track" in params
? sendAudio(chat, params)
: "page" in params
? sendPage(chat, params)
: sendMessage(chat, params);
? sendPage(chat, params)
: sendMessage(chat, params);

// Cache audio if any
if ("track" in params && result.audio?.file_id) {
yield* persistence().settings.store(
params.track.id.toString(),
result.audio.file_id
result.audio.file_id,
);
}

Expand Down Expand Up @@ -128,7 +128,7 @@ function replier(chat: number, name: string, group = true) {

function editor(chat: number) {
return function* (message: number, params: Message) {
yield* editMessageCaption(chat, message, params);
yield* async(editMessageCaption(chat, message, params));
};
}

Expand Down

0 comments on commit 09c84c1

Please sign in to comment.