tgcallsjs / gram-tgcalls

https://tgcallsjs.github.io/gram-tgcalls/
GNU Lesser General Public License v3.0
27 stars 4 forks source link

add skip method #1

Closed ArnabXD closed 3 years ago

rojvv commented 3 years ago

Do you know you just nearly duplicated the stop function but renamed it to skip?

Plus Stream.finish doesn't stop the stream.

ArnabXD commented 3 years ago

I see, I had some misunderstanding about stream.finish(). But Stream.stop() doesn't emit the 'finish' event either (tgcalls ref). I understand that my suggestion maybe not necessary to gram-tgcalls only if we emit finish event manually but gram-tgcalls doesn't provide access to stream or any way to emit finish manually either.. So shouldn't we add skip like this ->

    skip(chatId: number): boolean | null {
        const connection = this.#connections.get(chatId);

        if (connection) {
            if (!connection.stream.finished) {
                connection.stream.stop();
                connestion.stream.emit('finish')
                return true;
            }

            return false;
        }

        return null;
    }

otherwise onFinish won't even work right ?

rojvv commented 3 years ago

There's a PR on the tgcalls repo to make stop function emit finish.

We simply wait for @AndrewLaneX to merge it, and I will just update the required tgcalls version instead of making the lib a bloat.

Meanwhile, you can install a version of tgcalls which emits finish in stop function with: npm i callsmusic/tgcalls.

vrumger commented 3 years ago

We simply wait for @AndrewLaneX to merge it, and I will just update the required tgcalls version instead of making the lib a bloat.

Sorry for the delay, I merged the PR.