Skip to content

Instantly share code, notes, and snippets.

@uWynell
uWynell / BinaryClasses.js
Last active January 8, 2021 19:19
Classes for convenient work with binary data
class BinaryWriter {
constructor(buffer = [], offset = 0, littleEndian = true) {
this.view = new DataView(new ArrayBuffer(8));
this._buffer = [];
this.littleEndian = false;
if (Array.isArray(buffer)) {
this._buffer = buffer;
}
else if (buffer instanceof ArrayBuffer) {
this._buffer = Array.from(new Uint8Array(buffer));
@uWynell
uWynell / note.md
Last active May 24, 2023 04:49
Telegraf parallel handling

Introduction

Telegraf handles all requests sequentially, one after another. I won't get into details about why it might be done like that by default, but sometimes it's not really what you want.

So I had this problem too. While the bot was handling one heavy command, it could not handle other commands at the same time. Even if they were in different chats. That was quite a problem for me.

I didn't dive inside Telegraf, instead I just came up with a guess and it worked. I'm just sharing my experience, you might need to tweak the code for yourself a little.

Solutions