node-telegram-bot-api icon indicating copy to clipboard operation
node-telegram-bot-api copied to clipboard

Discussion: Refactor/Rewrite/Replace some parts of this library

Open kamikazechaser opened this issue 4 years ago • 9 comments

This library has some deprecated libraries e.g. request. Node.js has also progressed since when the core of this library was written; It has support for native promises/Async await e.t.c.

Some of the proposals are:

  1. Replace the bloated and deprecated request library with a more light weight alternative. The current proposals include: ethanent/phin, node-fetch/node-fetch, matthew-andrews/isomorphic-fetch, sindresorhus/got .The replacement library should support most of what request supported.

  2. Potentially replace Event Emitter 3 with a better drop in replacement like mcollina/mqemitter or native Event Emitter. This needs more research.

  3. Replace bluebird with native promises/async-await.

  4. Support Node.js v12+ as per LTS schedule. Any feature/polyfill supporting < v12 should be removed.

  5. Replace pump with pipeline.

Feel free to make your own proposals.

kamikazechaser avatar Feb 09 '21 16:02 kamikazechaser

  1. Move the samples/tutorials to a secondary repository
  2. Possibility of making an interactive documentation using documentationjs

danielperez9430 avatar Feb 10 '21 17:02 danielperez9430

Would transition to TypeScript be considered too?

I could help with that.

jmaister avatar Feb 24 '21 23:02 jmaister

Hey I would like to work on replacing the request library with node-fetch/node-fetch library

But the problem is what about the options.request parameter ? It is compatible with the old request library https://github.com/request/request#requestoptions-callback

varsubham avatar Apr 18 '21 10:04 varsubham

  1. Replace the bloated and deprecated request library with a more light weight alternative. The current proposals include: ethanent/phin, node-fetch/node-fetch, matthew-andrews/isomorphic-fetch, sindresorhus/got .The replacement library should support most of what request supported.

node-gyp goes with https://github.com/npm/make-fetch-happen

gengjiawen avatar Aug 19 '21 03:08 gengjiawen

I suggest https://github.com/telegraf/client. It's typed, and should be close to supporting https://grammy.dev/advanced/transformers.html.

wojpawlik avatar Dec 04 '21 11:12 wojpawlik

Agree with @wojpawlik, high time this library used a lite client like telegraf/client while keeping the API consistent with the current version so that there is no barrier to entry for existing devs.

Maybe even use middleware composition instead of event emitters.

kamikazechaser avatar Aug 14 '22 08:08 kamikazechaser

@telegraf/client was archived and is now being upstreamed into telegraf: https://github.com/telegraf/telegraf/pull/1705. I suggest you to just copy and adjust it to your needs.

Related to #1007.

wojpawlik avatar Sep 27 '22 09:09 wojpawlik

https://github.com/telegraf/telegraf/blob/v5/src/input.ts

wojpawlik avatar Sep 28 '22 13:09 wojpawlik

Do you have any news about migrating this amazing package to more lightwight?

  • I have very humble needs just to send a message to a channel - maybe there are simpler and lighter alternatives? I didn't find anything well-documented and maintained like node-telegram-bot-api
  • For now the package size is ~ 600k and startup time ~300ms on my local machine (fast and modern)

Doc999tor avatar Feb 23 '23 22:02 Doc999tor