From 9fbf2a10b329b946eddf6a233f12f1b74c322f0c Mon Sep 17 00:00:00 2001 From: KnorpelSenf Date: Mon, 3 Jun 2024 09:00:52 +0200 Subject: [PATCH] feat: allow cloning `Api` instances (#594) --- src/core/api.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/core/api.ts b/src/core/api.ts index a56a9cc3..a639b2f9 100644 --- a/src/core/api.ts +++ b/src/core/api.ts @@ -91,14 +91,23 @@ export class Api { readonly installedTransformers: () => Transformer[]; }; + /** + * Constructs a new instance of `Api`. It is independent from all other + * instances of this class. For example, this lets you install a custom set + * if transformers. + * + * @param token Bot API token obtained from [@BotFather](https://t.me/BotFather) + * @param options Optional API client options for the underlying client instance + * @param webhookReplyEnvelope Optional envelope to handle webhook replies + */ constructor( - token: string, - config?: ApiClientOptions, + public readonly token: string, + public readonly options?: ApiClientOptions, webhookReplyEnvelope?: WebhookReplyEnvelope, ) { const { raw, use, installedTransformers } = createRawApi( token, - config, + options, webhookReplyEnvelope, ); this.raw = raw;